rau cha
/
MPU6050-test-wihoutLib
For test MPU6050
Diff: main.cpp
- Revision:
- 0:897889ddd75a
- Child:
- 1:30c935175814
diff -r 000000000000 -r 897889ddd75a main.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Tue Jul 08 05:38:58 2014 +0000 @@ -0,0 +1,26 @@ +#include "mbed.h" +#include "MPU6050.h" + +Serial pc(USBTX,USBRX); +I2C i2c(p28,p27); + +int main() { + pc.printf("HelloWorld!!\n\r"); + MPU6050 dev(&i2c); + i2c.frequency(400000); + float accl[3]; + float gyro[3]; + while(1) { + dev.getAccelero(&accl[0]); + dev.getGyro(&gyro[0]); + pc.printf("\n\rAccl:"); + for(int i=0;i<3;i++) + pc.printf("%+08.4f ",accl[i]); + pc.printf(" Gyro:"); + for(int i=0;i<3;i++) + pc.printf("%+08.4f ",gyro[i]); + +// pc.printf("connected:%d\n\r", dev.testConnection()?1:0); + + } +}