Cirkit Designer LogoCirkit DesignerYour all-in-one circuit design IDE Launch Cirkit Designer App

Arduino UNO and MPU-6050 Based Motion Sensing System

View and Edit Project In Cirkit DesignerImage of Arduino UNO and MPU-6050 Based Motion Sensing System

Circuit Documentation

Summary

This document provides a detailed overview of a circuit that integrates an MPU-6050 accelerometer and gyroscope sensor with an Arduino UNO microcontroller. The MPU-6050 is used to capture motion data, which is then processed and output by the Arduino UNO.

Component List

MPU-6050

Arduino UNO

Wiring Details

MPU-6050

Arduino UNO

Code Documentation

Arduino UNO Code

#include "Wire.h"       
#include "I2Cdev.h"     
#include "MPU6050.h"    

MPU6050 mpu;
int16_t ax, ay, az;
int16_t gx, gy, gz;

struct MyData {
  byte X;
  byte Y;
  byte Z;
};

MyData data;

void setup()
{
  Serial.begin(9600);
  Wire.begin();
  mpu.initialize();
  //pinMode(LED_BUILTIN, OUTPUT);
}

void loop()
{
  mpu.getMotion6(&ax, &ay, &az, &gx, &gy, &gz);
  data.X = map(ax, -17000, 17000, 0, 255 ); // X axis data
  data.Y = map(ay, -17000, 17000, 0, 255); 
  data.Z = map(az, -17000, 17000, 0, 255);  // Y axis data
  delay(500);
  Serial.print("Axis X = ");
  Serial.print(data.X);
}

This code initializes the MPU-6050 sensor and reads the accelerometer and gyroscope data. The data is then mapped to a range of 0 to 255 and printed to the serial monitor. The setup() function initializes the serial communication and the MPU-6050 sensor, while the loop() function continuously reads the sensor data and outputs it.