#include <Wire.h>
#define MPU 0x68 // MPU6050 address when ADO = GND
void setup() {
Serial.begin(115200);
Wire.begin();
// Wake up MPU6050
Wire.beginTransmission(MPU);
Wire.write(0x6B);
Wire.write(0);
Wire.endTransmission(true);
Serial.println("MPU6050 Ready...");
}
void loop() {
Wire.beginTransmission(MPU);
Wire.write(0x3B); // start reading at ACCEL_XOUT_H
Wire.endTransmission(false);
Wire.requestFrom(MPU, 14, true);
int16_t ax = Wire.read() << 8 | Wire.read();
int16_t ay = Wire.read() << 8 | Wire.read();
int16_t az = Wire.read() << 8 | Wire.read();
int16_t temp = Wire.read() << 8 | Wire.read();
int16_t gx = Wire.read() << 8 | Wire.read();
int16_t gy = Wire.read() << 8 | Wire.read();
int16_t gz = Wire.read() << 8 | Wire.read();
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.print(gz);
Serial.println();
delay(100);
}