Sofia Wheelchair MPU6050
Embed:
(wiki syntax)
Show/hide line numbers
main.cpp
00001 //include libraries in cpp file 00002 #include "mbed.h" 00003 #include "MPU6050.h" 00004 //creating an object of serial class so that we can communicate with PC 00005 Serial pc(SERIAL_TX, SERIAL_RX); 00006 //creating object of MPU6050 class 00007 MPU6050 ark(PB_9,PB_8); 00008 int main() 00009 { 00010 while(1) 00011 { 00012 //reading Grometer readings 00013 float gyro[3]; 00014 ark.getGyro(gyro); 00015 pc.printf("Gyro X = %f\r\n",gyro[0]); 00016 pc.printf("Gyro Y = %f\r\n",gyro[1]); 00017 pc.printf("Gyro Z = %f\r\n",gyro[2]); 00018 pc.printf("\r\n"); 00019 //reading Acclerometer readings 00020 float acce[3]; 00021 ark.getAccelero(acce); 00022 pc.printf("Acce X = %f\r\n",acce[0]); 00023 pc.printf("Acce Y = %f\r\n",acce[1]); 00024 pc.printf("Acce Z = %f\r\n",acce[2]); 00025 pc.printf("\r\n"); 00026 wait(1); //wait 1000ms 00027 } 00028 }
Generated on Thu Jul 28 2022 05:10:51 by
1.7.2