mup6050 test for wallbot ble(led)

Dependencies:   MPU6050 mbed

Fork of mpu6050_test by Simon Garfieldsg

Revision:
1:4fb56c1cfd3d
Parent:
0:84dda456d02c
--- a/main.cpp	Fri Jan 11 00:58:23 2013 +0000
+++ b/main.cpp	Mon Apr 23 07:05:08 2018 +0000
@@ -1,32 +1,26 @@
 #include "mbed.h"
 #include "MPU6050.h"
+#define MPU6050_ADDRESS 0x68
 
 DigitalOut myled(LED1);
 Serial pc(USBTX, USBRX);
-MPU6050 mpu;
-
-int16_t ax, ay, az;
-int16_t gx, gy, gz;
+MPU6050 mpu(I2C_SDA,I2C_SCL);
 
 int main()
 {
-    pc.printf("MPU6050 test\n\n");
-    pc.printf("MPU6050 initialize \n");
 
-    mpu.initialize();
-    pc.printf("MPU6050 testConnection \n");
-
-    bool mpu6050TestResult = mpu.testConnection();
-    if(mpu6050TestResult) {
-        pc.printf("MPU6050 test passed \n");
-    } else {
-        pc.printf("MPU6050 test failed \n");
-    }
-   
+    float a[3];
+    float g[3];
+    mpu.setAcceleroRange(0);
+    mpu.setGyroRange(0);
+    
     while(1) {
-        wait(1);
-        mpu.getMotion6(&ax, &ay, &az, &gx, &gy, &gz);
-        //writing current accelerometer and gyro position 
-        pc.printf("%d;%d;%d;%d;%d;%d\n",ax,ay,az,gx,gy,gz);
+        myled = 1;
+        wait(0.1);
+        myled = 0;
+        wait(0.1);
+        mpu.getAccelero(a);
+        mpu.getGyro(g);
+        pc.printf("%4.3f,%4.3f,%4.3f,%4.3f,%4.3f,%4.3f\r\n",a[0],a[1],a[2],g[0],g[1],g[2]);
     }
 }