Gyroscope Experiment with MPU6050

Gyroscope Experiment with MPU6050

Objective

This experiment uses the MPU6050 gyroscope to measure the angular velocity and orientation of an object.

Required Components

Working Principle

The MPU6050 contains both a gyroscope and an accelerometer that measure angular velocity and acceleration, respectively.

Circuit Diagram

MPU6050 Circuit Diagram

Arduino Code


/*
 * Gyroscope Experiment with MPU6050
 * This code reads the gyroscope data from the MPU6050 sensor.
 */

#include 
#include 

MPU6050 mpu;

void setup() {
  Serial.begin(9600);  
  Wire.begin();
  mpu.initialize();
  if (!mpu.testConnection()) {
    Serial.println("MPU6050 connection failed");
    while (1);
  }
}

void loop() {
  int16_t ax, ay, az;
  int16_t gx, gy, gz;
  mpu.getMotion6(&ax, &ay, &az, &gx, &gy, &gz);

  Serial.print("Gyroscope X: ");
  Serial.print(gx);
  Serial.print(" Y: ");
  Serial.print(gy);
  Serial.print(" Z: ");
  Serial.println(gz);
  delay(1000);
}
            

Results

The serial monitor will display the angular velocity in degrees per second for the X, Y, and Z axes.

Applications

Conclusion

The MPU6050 gyroscope provides valuable data on angular velocity and orientation, which can be applied to robotics, drones, and wearable motion tracking devices.