GROVE - 3軸加速度センサ サンプルプログラム

Dependencies:   MMA7660FC mbed

Fork of TestCode_MMA7660FC by Edoardo De Marchi

Revision:
2:152191e37eb1
Parent:
1:78138640bd0e
diff -r 78138640bd0e -r 152191e37eb1 main.cpp
--- a/main.cpp	Wed Jul 04 20:22:15 2012 +0000
+++ b/main.cpp	Thu Jul 05 17:48:44 2012 +0000
@@ -26,16 +26,16 @@
     {   
         float x=0, y=0, z=0;
         
-        Acc.read_Tilt(&x, &y, &z);                                     // Read the acceleration                    
+        Acc.read_Tilt(&x, &y, &z);                                  // Read the acceleration                    
         pc.printf("Tilt x: %2.2f degree \n", x);                    // Print the tilt orientation of the X axis
         pc.printf("Tilt y: %2.2f degree \n", y);                    // Print the tilt orientation of the Y axis
         pc.printf("Tilt z: %2.2f degree \n", z);                    // Print the tilt orientation of the Z axis
 
         wait_ms(100);
 
-        pc.printf("x: %2.0f \n", Acc.read_z());                      // Print the X axis acceleration
-        pc.printf("y: %2.0f \n", Acc.read_y());                      // Print the Y axis acceleration
-        pc.printf("z: %2.0f \n", Acc.read_z());                      // Print the Z axis acceleration
+        pc.printf("x: %1.3f g \n", G_VALUE[Acc.read_x()]);          // Print the X axis acceleration
+        pc.printf("y: %1.3f g \n", G_VALUE[Acc.read_y()]);          // Print the Y axis acceleration
+        pc.printf("z: %1.3f g \n", G_VALUE[Acc.read_z()]);          // Print the Z axis acceleration
         pc.printf("\n");
         wait(5);