#include <Adafruit_MPU6050.h>
#include <Adafruit_Sensor.h>
#include <Wire.h>
Adafruit_MPU6050 mpu;
void setup(void) {
/*
mpu.setAccelerometerRange(MPU6050_RANGE_16_G);
mpu.setGyroRange(MPU6050_RANGE_250_DEG);
mpu.setFilterBandwidth(MPU6050_BAND_21_HZ);
*/
Serial.begin(115200);
while (!mpu.begin()) {
Serial.println("MPU6050 not connected!");
delay(1000);
}
Serial.println("MPU6050 ready!");
}
sensors_event_t event;
void loop() {
/* Get new sensor events with the readings */
mpu.getAccelerometerSensor()->getEvent(&event);
Serial.print("[");
Serial.print(millis());
Serial.print("] X: ");
Serial.print(event.acceleration.x);
Serial.print(", Y: ");
Serial.print(event.acceleration.y);
Serial.print(", Z: ");
Serial.print(event.acceleration.z);
Serial.print(" , ");
Serial.print(event.gyro.x);
Serial.print(", Y: ");
Serial.print(event.gyro.y);
Serial.print(", Z: ");
Serial.print(event.gyro.z);
Serial.print(" m/s^2 Deg: ");
Serial.print(event.temperature);
Serial.println("");
delay(500);
}