Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
main.cpp
00001 #include "mbed.h" 00002 #include "MPU6050.h" 00003 #include "REFVALUES.h" 00004 //activo 00005 // Debbuging led 00006 DigitalOut myled(LED1); 00007 // klkl 00008 // Puerto serial 00009 Serial pc(USBTX, USBRX); 00010 00011 // Objeto MPU6050 00012 MPU6050 mpu(PF_15, PF_14); 00013 00014 // Threads 00015 Thread sampleAccelero(); 00016 Thread printDebug(); 00017 00018 //Mutex 00019 Mutex semaforo; 00020 00021 //Mailbox 00022 Mail<float, 1> mail_box; 00023 00024 00025 00026 00027 void medicion() { 00028 00029 pc.baud(9600); 00030 00031 00032 00033 float acce[3]; 00034 00035 mpu.setAcceleroRange(2); 00036 mpu.setBW(6); 00037 00038 // Test the connection 00039 if (mpu.testConnection()) 00040 pc.printf("MPU6050 test passed \r\n"); 00041 else 00042 pc.printf("MPU6050 test failed \r\n"); 00043 00044 00045 float x; 00046 float y; 00047 00048 while(1) { 00049 00050 wait(0.016); 00051 mpu.getAccelero(acce); 00052 00053 00054 x = (float)acce[0] / (9.81); 00055 y = (float)acce[1] / (9.81); 00056 00057 00058 //pc.printf("X = %f \t Y = %f \t Z = %f \r\n", x , y, z); 00059 pc.printf("X = %f \t Y = %f \r\n", x , y); 00060 //pc.printf("%f\r\n", x); 00061 00062 } 00063 } 00064 00065 int main() 00066 { 00067 sampleAccelero.start(medicion); 00068 }
Generated on Thu Jul 28 2022 16:48:02 by
1.7.2