![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
meka_test
Fork of mpu6050_test by
main.cpp@0:84dda456d02c, 2013-01-11 (annotated)
- Committer:
- garfieldsg
- Date:
- Fri Jan 11 00:58:23 2013 +0000
- Revision:
- 0:84dda456d02c
test of mpu6050
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
garfieldsg | 0:84dda456d02c | 1 | #include "mbed.h" |
garfieldsg | 0:84dda456d02c | 2 | #include "MPU6050.h" |
garfieldsg | 0:84dda456d02c | 3 | |
garfieldsg | 0:84dda456d02c | 4 | DigitalOut myled(LED1); |
garfieldsg | 0:84dda456d02c | 5 | Serial pc(USBTX, USBRX); |
garfieldsg | 0:84dda456d02c | 6 | MPU6050 mpu; |
garfieldsg | 0:84dda456d02c | 7 | |
garfieldsg | 0:84dda456d02c | 8 | int16_t ax, ay, az; |
garfieldsg | 0:84dda456d02c | 9 | int16_t gx, gy, gz; |
garfieldsg | 0:84dda456d02c | 10 | |
garfieldsg | 0:84dda456d02c | 11 | int main() |
garfieldsg | 0:84dda456d02c | 12 | { |
garfieldsg | 0:84dda456d02c | 13 | pc.printf("MPU6050 test\n\n"); |
garfieldsg | 0:84dda456d02c | 14 | pc.printf("MPU6050 initialize \n"); |
garfieldsg | 0:84dda456d02c | 15 | |
garfieldsg | 0:84dda456d02c | 16 | mpu.initialize(); |
garfieldsg | 0:84dda456d02c | 17 | pc.printf("MPU6050 testConnection \n"); |
garfieldsg | 0:84dda456d02c | 18 | |
garfieldsg | 0:84dda456d02c | 19 | bool mpu6050TestResult = mpu.testConnection(); |
garfieldsg | 0:84dda456d02c | 20 | if(mpu6050TestResult) { |
garfieldsg | 0:84dda456d02c | 21 | pc.printf("MPU6050 test passed \n"); |
garfieldsg | 0:84dda456d02c | 22 | } else { |
garfieldsg | 0:84dda456d02c | 23 | pc.printf("MPU6050 test failed \n"); |
garfieldsg | 0:84dda456d02c | 24 | } |
garfieldsg | 0:84dda456d02c | 25 | |
garfieldsg | 0:84dda456d02c | 26 | while(1) { |
garfieldsg | 0:84dda456d02c | 27 | wait(1); |
garfieldsg | 0:84dda456d02c | 28 | mpu.getMotion6(&ax, &ay, &az, &gx, &gy, &gz); |
garfieldsg | 0:84dda456d02c | 29 | //writing current accelerometer and gyro position |
garfieldsg | 0:84dda456d02c | 30 | pc.printf("%d;%d;%d;%d;%d;%d\n",ax,ay,az,gx,gy,gz); |
garfieldsg | 0:84dda456d02c | 31 | } |
garfieldsg | 0:84dda456d02c | 32 | } |