![](/media/cache/group/default_image.jpg.50x50_q85.jpg)
test kl25 mpu6050
main.cpp
- Committer:
- Javierdf
- Date:
- 2019-11-19
- Revision:
- 1:9ab6fa1b0541
- Parent:
- 0:84dda456d02c
File content as of revision 1:9ab6fa1b0541:
#include "mbed.h" #include "MPU6050.h" //#include "device.h" DigitalOut myled(LED1); Serial pc(USBTX, USBRX); MPU6050 mpu; int16_t ax, ay, az; int16_t gx, gy, gz; int main() { pc.printf("MPU6050 test\n\n"); pc.printf("MPU6050 initialize \n"); mpu.initialize(); pc.printf("MPU6050 testConnection \n"); bool mpu6050TestResult = mpu.testConnection(); if(mpu6050TestResult) { pc.printf("MPU6050 test passed \n"); } else { pc.printf("MPU6050 test failed \n"); } while(1) { wait(1); mpu.getMotion6(&ax, &ay, &az, &gx, &gy, &gz); //writing current accelerometer and gyro position pc.printf("%d;%d;%d;%d;%d;%d\n",ax,ay,az,gx,gy,gz); } }