mpu6050

Dependencies:   mbed MPU6050

Committer:
TimothyDaw
Date:
Fri Feb 28 18:48:19 2020 +0000
Revision:
0:68bfb6ebd7a1
mpu6050

Who changed what in which revision?

UserRevisionLine numberNew contents of line
TimothyDaw 0:68bfb6ebd7a1 1 //include libraries in cpp file
TimothyDaw 0:68bfb6ebd7a1 2 #include "mbed.h"
TimothyDaw 0:68bfb6ebd7a1 3 #include "MPU6050.h"
TimothyDaw 0:68bfb6ebd7a1 4 //creating an object of serial class
TimothyDaw 0:68bfb6ebd7a1 5 //so that we can communicate with PC
TimothyDaw 0:68bfb6ebd7a1 6 Serial pc(SERIAL_TX, SERIAL_RX);
TimothyDaw 0:68bfb6ebd7a1 7 //setting LED1 to give digital output
TimothyDaw 0:68bfb6ebd7a1 8 DigitalOut myled(LED1);
TimothyDaw 0:68bfb6ebd7a1 9 //creating onject of MPU6050 class
TimothyDaw 0:68bfb6ebd7a1 10 MPU6050 ark(PB_9,PB_8);
TimothyDaw 0:68bfb6ebd7a1 11 int main()
TimothyDaw 0:68bfb6ebd7a1 12 {
TimothyDaw 0:68bfb6ebd7a1 13 pc.printf("test");
TimothyDaw 0:68bfb6ebd7a1 14 while(1) {
TimothyDaw 0:68bfb6ebd7a1 15 //reading Temprature
TimothyDaw 0:68bfb6ebd7a1 16 //float temp = ark.getTemp();
TimothyDaw 0:68bfb6ebd7a1 17 // pc.printf("temprature = %0.2f ^C\r\n",temp);
TimothyDaw 0:68bfb6ebd7a1 18
TimothyDaw 0:68bfb6ebd7a1 19 //reading Grometer readings
TimothyDaw 0:68bfb6ebd7a1 20 float gyro[3];
TimothyDaw 0:68bfb6ebd7a1 21 ark.getGyro(gyro);
TimothyDaw 0:68bfb6ebd7a1 22 pc.printf("MPU0\n\r%f, \t%f, \t%f,",gyro[0],gyro[1],gyro[2]);
TimothyDaw 0:68bfb6ebd7a1 23
TimothyDaw 0:68bfb6ebd7a1 24 //reading Acclerometer readings
TimothyDaw 0:68bfb6ebd7a1 25 float acce[3];
TimothyDaw 0:68bfb6ebd7a1 26 ark.getAccelero(acce);
TimothyDaw 0:68bfb6ebd7a1 27 pc.printf(" %f, %f, %f\r\n************\n\r",acce[0],acce[1],acce[2]);
TimothyDaw 0:68bfb6ebd7a1 28
TimothyDaw 0:68bfb6ebd7a1 29
TimothyDaw 0:68bfb6ebd7a1 30 //reading Grometer readings
TimothyDaw 0:68bfb6ebd7a1 31 float gyro1[3];
TimothyDaw 0:68bfb6ebd7a1 32 ark.getGyro(gyro);
TimothyDaw 0:68bfb6ebd7a1 33 pc.printf("MPU1\n\r%f, \t%f, \t%f,",gyro[0],gyro[1],gyro[2]);
TimothyDaw 0:68bfb6ebd7a1 34
TimothyDaw 0:68bfb6ebd7a1 35 //reading Acclerometer readings
TimothyDaw 0:68bfb6ebd7a1 36 float acce1[3];
TimothyDaw 0:68bfb6ebd7a1 37 ark.getAccelero(acce);
TimothyDaw 0:68bfb6ebd7a1 38 pc.printf(" %f, %f, %f\r\n*****6969********\n\r",acce[0],acce[1],acce[2]);
TimothyDaw 0:68bfb6ebd7a1 39 wait(0.1); //wait
TimothyDaw 0:68bfb6ebd7a1 40 }
TimothyDaw 0:68bfb6ebd7a1 41 }