//filename: w10 up exercise Arduino UNO IMU practice (20221114)v2
#include <Adafruit_MPU6050.h> //include MPU6050 IMU library
#include <Adafruit_Sensor.h>
//#include <wire.h>
//user define function, IMU library
Adafruit_MPU6050 mpu;
void setup() {
// put your setup code here, to run once:
Serial.begin(19200);
Serial.println("IMU test...");
while ( !mpu.begin() ) {
Serial.println("IMU not connected.");
delay(1000);
}
Serial.println("IMU is ready.");
}
sensors_event_t event;
void loop() {
mpu.getAccelerometerSensor()->getEvent(&event);
Serial.print("[ ");
Serial.print(millis());
Serial.print("] X:"); //show acc. x
Serial.print(event.acceleration.x);
Serial.print("] Y:"); //show acc. x
Serial.print(event.acceleration.y);
Serial.print("] Z:"); //show acc. x
Serial.print(event.acceleration.z);
}