rau cha
/
MPU6050-test-wihoutLib
For test MPU6050
main.cpp@0:897889ddd75a, 2014-07-08 (annotated)
- Committer:
- Shikaneo
- Date:
- Tue Jul 08 05:38:58 2014 +0000
- Revision:
- 0:897889ddd75a
- Child:
- 1:30c935175814
first commit
Who changed what in which revision?
User | Revision | Line number | New 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 | 0:897889ddd75a | 8 | pc.printf("HelloWorld!!\n\r"); |
Shikaneo | 0:897889ddd75a | 9 | MPU6050 dev(&i2c); |
Shikaneo | 0:897889ddd75a | 10 | i2c.frequency(400000); |
Shikaneo | 0:897889ddd75a | 11 | float accl[3]; |
Shikaneo | 0:897889ddd75a | 12 | float gyro[3]; |
Shikaneo | 0:897889ddd75a | 13 | while(1) { |
Shikaneo | 0:897889ddd75a | 14 | dev.getAccelero(&accl[0]); |
Shikaneo | 0:897889ddd75a | 15 | dev.getGyro(&gyro[0]); |
Shikaneo | 0:897889ddd75a | 16 | pc.printf("\n\rAccl:"); |
Shikaneo | 0:897889ddd75a | 17 | for(int i=0;i<3;i++) |
Shikaneo | 0:897889ddd75a | 18 | pc.printf("%+08.4f ",accl[i]); |
Shikaneo | 0:897889ddd75a | 19 | pc.printf(" Gyro:"); |
Shikaneo | 0:897889ddd75a | 20 | for(int i=0;i<3;i++) |
Shikaneo | 0:897889ddd75a | 21 | pc.printf("%+08.4f ",gyro[i]); |
Shikaneo | 0:897889ddd75a | 22 | |
Shikaneo | 0:897889ddd75a | 23 | // pc.printf("connected:%d\n\r", dev.testConnection()?1:0); |
Shikaneo | 0:897889ddd75a | 24 | |
Shikaneo | 0:897889ddd75a | 25 | } |
Shikaneo | 0:897889ddd75a | 26 | } |