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.
Diff: main.cpp
- Revision:
- 0:43edf2e11fc0
- Child:
- 1:741df8410d1f
- Child:
- 2:4fa4c952883a
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Fri Jul 26 00:06:28 2019 +0000
@@ -0,0 +1,58 @@
+#include "mbed.h"
+#include "MPU6050.h"
+#include "REFVALUES.h"
+
+// Debbuging led
+DigitalOut myled(LED1);
+
+// Puerto serial
+Serial pc(USBTX, USBRX);
+
+// Objeto MPU6050
+MPU6050 mpu(PF_15, PF_14);
+
+// Threads
+Thread sampleAccelero();
+Thread printDebug();
+ 
+
+
+
+
+int main() {
+    
+    pc.baud(9600);
+    
+    
+    
+    float acce[3];
+    
+    mpu.setAcceleroRange(2);
+    mpu.setBW(6);
+   
+    // Test the connection
+    if (mpu.testConnection())
+        pc.printf("MPU6050 test passed \r\n");    
+    else
+        pc.printf("MPU6050 test failed \r\n");
+    
+    
+    float x;
+    float y;
+    
+    while(1) {
+        
+        wait(0.016);
+        mpu.getAccelero(acce);
+        
+        
+        x = (float)acce[0] / (9.81);
+        y = (float)acce[1] / (9.81);
+            
+        
+        //pc.printf("X = %f  \t Y = %f \t Z = %f \r\n", x , y, z);
+        pc.printf("X = %f  \t Y = %f \r\n", x , y);
+        //pc.printf("%f\r\n", x);
+    
+    }
+}
    