#include <Wire.h>
#include <MPU6050.h>
MPU6050 mpu;
void setup() {
Serial.begin(9600);
// Initialize the MPU6050 sensor
Wire.begin();
mpu.initialize();
// Configure the MPU6050 sensor
mpu.setFullScaleAccelRange(MPU6050_ACCEL_FS_2);
mpu.setFullScaleGyroRange(MPU6050_GYRO_FS_250);
}
void loop() {
// Read accelerometer and gyroscope data
int16_t ax, ay, az;
int16_t gx, gy, gz;
mpu.getMotion6(&ax, &ay, &az, &gx, &gy, &gz);
// Print accelerometer data
Serial.print("Accelerometer (mg): ");
Serial.print("X=");
Serial.print(ax);
Serial.print(", Y=");
Serial.print(ay);
Serial.print(", Z=");
Serial.println(az);
// Print gyroscope data
Serial.print("Gyroscope (degrees/sec): ");
Serial.print("X=");
Serial.print(gx);
Serial.print(", Y=");
Serial.print(gy);
Serial.print(", Z=");
Serial.println(gz);
delay(1000); // Adjust delay as needed
}