Esdras Nicolás Rodríguez Lantigua
/
MPU6050Test
Sofia Wheelchair MPU6050
Diff: main.cpp
- Revision:
- 0:183a252cfa2a
diff -r 000000000000 -r 183a252cfa2a main.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Fri Jul 16 01:59:43 2021 +0000 @@ -0,0 +1,28 @@ +//include libraries in cpp file +#include "mbed.h" +#include "MPU6050.h" +//creating an object of serial class so that we can communicate with PC +Serial pc(SERIAL_TX, SERIAL_RX); +//creating object of MPU6050 class +MPU6050 ark(PB_9,PB_8); +int main() +{ + while(1) + { + //reading Grometer readings + float gyro[3]; + ark.getGyro(gyro); + pc.printf("Gyro X = %f\r\n",gyro[0]); + pc.printf("Gyro Y = %f\r\n",gyro[1]); + pc.printf("Gyro Z = %f\r\n",gyro[2]); + pc.printf("\r\n"); + //reading Acclerometer readings + float acce[3]; + ark.getAccelero(acce); + pc.printf("Acce X = %f\r\n",acce[0]); + pc.printf("Acce Y = %f\r\n",acce[1]); + pc.printf("Acce Z = %f\r\n",acce[2]); + pc.printf("\r\n"); + wait(1); //wait 1000ms + } +} \ No newline at end of file