

_0x0_webp.jpg)
The MPU-6050 is a super popular motion-tracking sensor that combines a 3-axis gyroscope and a 3-axis accelerometer in a single chip. It’s widely used in DIY electronics, robotics, drones, and mobile devices to detect motion, orientation, and acceleration.
Feature Details
Gyroscope Measures angular velocity (rotation) in X, Y, Z axis
Accelerometer Measures acceleration (tilt, motion, gravity) in X, Y, Z axes
Interface I²C (Inter-Integrated Circuit)
Power Supply 3.3V or 5V depending on breakout board
Onboard DMP Digital Motion Processor – can do sensor fusion for orientation (e.g., pitch, roll, yaw)
Here’s how to connect it to an Arduino Uno:
PinVCC 5V or 3.3V
GND GND
SDA A4 (on Uno)
SCL A5 (on Uno)
Using the Wire.h library and optionally the MPU6050 or I2Cdev library:
#include <Wire.h>
#include <MPU6050.h>
MPU6050 mpu;
void setup() {
  Wire.begin();
  Serial.begin(9600);
  mpu.initialize();
  if (mpu.testConnection()) {
    Serial.println("MPU6050 connected");
  } else {
    Serial.println("MPU6050 connection failed");
  }
}
void loop() {
  int16_t ax, ay, az;
  int16_t gx, gy, gz;
  mpu.getMotion6(&ax, &ay, &az, &gx, &gy, &gz);
  Serial.print("Accel: ");
  Serial.print(ax); Serial.print(" ");
  Serial.print(ay); Serial.print(" ");
  Serial.print(az); Serial.print(" | Gyro: ");
  Serial.print(gx); Serial.print(" ");
  Serial.print(gy); Serial.print(" ");
  Serial.println(gz);
  delay(500);
}