MPU6050 library test

Dependencies:   mbed MPU6050

Revision:
0:5efae55d7fbb
Child:
1:01af59327884
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Mon Sep 19 05:35:56 2016 +0000
@@ -0,0 +1,26 @@
+#include "mbed.h"
+#include "MPU6050.h"
+
+MPU6050 mpu(D7,D8);//for Nucleo-F042K6
+Serial pc(USBTX,USBRX);
+
+float gx,gy,gz,ax,ay,az;
+
+int main()
+{
+    pc.baud(115200);
+    if(mpu.getID()==0x68) {
+        pc.printf("MPU6050 OK");
+        wait(1);
+    } else {
+        pc.printf("MPU6050 error ID=0x%x\r\n",mpu.getID());
+        while(1) {
+        }
+    }
+    mpu.start();
+    while(1) {
+        mpu.read(&gx,&gy,&gz,&ax,&ay,&az);
+        pc.printf("gx,gy,gz,ax,ay,az %.1f,%.1f,%.1f,%.2f,%.2f,%.2f\r\n",gx,gy,gz,ax,ay,az);
+        wait(0.1);
+    }
+}
\ No newline at end of file