x

Dependencies:   MPU6050 mbed

Committer:
rm_9x
Date:
Tue Nov 21 15:55:27 2017 +0000
Revision:
0:2a12e1a40be5
x

Who changed what in which revision?

UserRevisionLine numberNew contents of line
rm_9x 0:2a12e1a40be5 1 #include "mbed.h"
rm_9x 0:2a12e1a40be5 2 #include "MPU6050.h"
rm_9x 0:2a12e1a40be5 3
rm_9x 0:2a12e1a40be5 4 Serial pc(USBTX, USBRX); // tx, rx
rm_9x 0:2a12e1a40be5 5 MPU6050 mpu(p9, p10); //Also disables sleep mode
rm_9x 0:2a12e1a40be5 6
rm_9x 0:2a12e1a40be5 7 int main() {
rm_9x 0:2a12e1a40be5 8 int accdata[3];
rm_9x 0:2a12e1a40be5 9 int gyrodata[3];
rm_9x 0:2a12e1a40be5 10
rm_9x 0:2a12e1a40be5 11 wait(0.1);
rm_9x 0:2a12e1a40be5 12 if (mpu.testConnection())
rm_9x 0:2a12e1a40be5 13 pc.printf("MPU connection succeeded\n\r");
rm_9x 0:2a12e1a40be5 14 else
rm_9x 0:2a12e1a40be5 15 pc.printf("MPU connection failed\n\r");
rm_9x 0:2a12e1a40be5 16
rm_9x 0:2a12e1a40be5 17 while(1) {
rm_9x 0:2a12e1a40be5 18 mpu.getAcceleroRaw(accdata);
rm_9x 0:2a12e1a40be5 19 mpu.getGyroRaw(gyrodata);
rm_9x 0:2a12e1a40be5 20
rm_9x 0:2a12e1a40be5 21 pc.printf("Accelero data: X: %d - Y: %d - Z: %d\n\r", accdata[0], accdata[1], accdata[2]);
rm_9x 0:2a12e1a40be5 22 pc.printf("Gyro data: X: %d - Y: %d - Z: %d\n\r\n\r", gyrodata[0], gyrodata[1], gyrodata[2]);
rm_9x 0:2a12e1a40be5 23
rm_9x 0:2a12e1a40be5 24 wait(1);
rm_9x 0:2a12e1a40be5 25 }
rm_9x 0:2a12e1a40be5 26
rm_9x 0:2a12e1a40be5 27
rm_9x 0:2a12e1a40be5 28 }