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 circuit involves an Arduino UNO microcontroller interfaced with an MPU-6050 accelerometer and gyroscope sensor. The Arduino UNO reads data from the MPU-6050 and processes it to output the accelerometer readings on the serial monitor.

Component List

Arduino UNO

MPU-6050

L293D Motor Driver

Wiring Details

Arduino UNO

MPU-6050

L293D Motor Driver

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);
  Serial.print("  ");
  Serial.print("Axis Y = ");
  Serial.print(data.Y);
  Serial.print("  ");
  Serial.print("Axis Z  = ");
  Serial.println(data.Z);
}

This code initializes the MPU-6050 sensor and reads the accelerometer data in the loop. The data is then mapped to a range of 0 to 255 and printed to the serial monitor.