#include #include #include #include "I2Cdev.h" #include "MPU6050.h" // class default I2C address is 0x68 // specific I2C addresses may be passed as a parameter here // AD0 low = 0x68 (default for InvenSense evaluation board) // AD0 high = 0x69 MPU6050 accelgyro; int16_t ax, ay, az; int16_t gx, gy, gz; void setup() { // initialize device printf("Initializing I2C devices...\n"); accelgyro.initialize(); // verify connection printf("Testing device connections...\n"); printf(accelgyro.testConnection() ? "MPU6050 connection successful\n" : "MPU6050 connection failed\n"); } void loop() { // read raw accel/gyro measurements from device accelgyro.getMotion6(&ax, &ay, &az, &gx, &gy, &gz); // these methods (and a few others) are also available //accelgyro.getAcceleration(&ax, &ay, &az); //accelgyro.getRotation(&gx, &gy, &gz); // display accel/gyro x/y/z values printf("a/g: %6hd %6hd %6hd %6hd %6hd %6hd\n",ax,ay,az,gx,gy,gz); } int main() { setup(); for (;;) loop(); }