For test MPU6050

Dependencies:   mbed

Committer:
Shikaneo
Date:
Tue Jul 08 05:44:14 2014 +0000
Revision:
1:30c935175814
Parent:
0:897889ddd75a
*modified baudrate; *add mbed lib

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Shikaneo 0:897889ddd75a 1 #include "mbed.h"
Shikaneo 0:897889ddd75a 2 #include "MPU6050.h"
Shikaneo 0:897889ddd75a 3
Shikaneo 0:897889ddd75a 4 Serial pc(USBTX,USBRX);
Shikaneo 0:897889ddd75a 5 I2C i2c(p28,p27);
Shikaneo 0:897889ddd75a 6
Shikaneo 0:897889ddd75a 7 int main() {
Shikaneo 1:30c935175814 8 pc.baud(921600);
Shikaneo 0:897889ddd75a 9 pc.printf("HelloWorld!!\n\r");
Shikaneo 0:897889ddd75a 10 MPU6050 dev(&i2c);
Shikaneo 0:897889ddd75a 11 i2c.frequency(400000);
Shikaneo 0:897889ddd75a 12 float accl[3];
Shikaneo 0:897889ddd75a 13 float gyro[3];
Shikaneo 0:897889ddd75a 14 while(1) {
Shikaneo 0:897889ddd75a 15 dev.getAccelero(&accl[0]);
Shikaneo 0:897889ddd75a 16 dev.getGyro(&gyro[0]);
Shikaneo 0:897889ddd75a 17 pc.printf("\n\rAccl:");
Shikaneo 0:897889ddd75a 18 for(int i=0;i<3;i++)
Shikaneo 0:897889ddd75a 19 pc.printf("%+08.4f ",accl[i]);
Shikaneo 0:897889ddd75a 20 pc.printf(" Gyro:");
Shikaneo 0:897889ddd75a 21 for(int i=0;i<3;i++)
Shikaneo 0:897889ddd75a 22 pc.printf("%+08.4f ",gyro[i]);
Shikaneo 0:897889ddd75a 23
Shikaneo 0:897889ddd75a 24 // pc.printf("connected:%d\n\r", dev.testConnection()?1:0);
Shikaneo 0:897889ddd75a 25
Shikaneo 0:897889ddd75a 26 }
Shikaneo 0:897889ddd75a 27 }