Demo for Accel

Dependencies:   MMA8451Q mbed

Fork of FRDM_MMA8451Q by Sivasai Praneeth Nanduri

Files at this revision

API Documentation at this revision

Comitter:
sam_grove
Date:
Wed Jul 16 10:30:54 2014 +0000
Parent:
8:d797bfa9f76e
Commit message:
update example x,y,z printed values, formatting and mbed library. Add support for FRDM-K20D50M

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed.bld Show annotated file Show diff for this revision Revisions of this file
--- a/main.cpp	Fri Feb 21 15:33:38 2014 +0000
+++ b/main.cpp	Wed Jul 16 10:30:54 2014 +0000
@@ -7,26 +7,33 @@
 #elif defined (TARGET_KL05Z)
   PinName const SDA = PTB4;
   PinName const SCL = PTB3;
+#elif defined (TARGET_K20D50M)
+  PinName const SDA = PTB1;
+  PinName const SCL = PTB0;
 #else
   #error TARGET NOT DEFINED
 #endif
 
 #define MMA8451_I2C_ADDRESS (0x1d<<1)
 
-int main(void) {
+int main(void)
+{
     MMA8451Q acc(SDA, SCL, MMA8451_I2C_ADDRESS);
     PwmOut rled(LED1);
     PwmOut gled(LED2);
     PwmOut bled(LED3);
-    
+
     printf("MMA8451 ID: %d\n", acc.getWhoAmI());
 
     while (true) {
         float x, y, z;
-        x = rled = 1.0 - abs(acc.getAccX());
-        y = gled = 1.0 - abs(acc.getAccY());
-        z = bled = 1.0 - abs(acc.getAccZ());
-        wait(0.1);
+        x = abs(acc.getAccX());
+        y = abs(acc.getAccY());
+        z = abs(acc.getAccZ());
+        rled = 1.0f - x;
+        gled = 1.0f - y;
+        bled = 1.0f - z;
+        wait(0.1f);
         printf("X: %1.2f, Y: %1.2f, Z: %1.2f\n", x, y, z);
     }
 }
--- a/mbed.bld	Fri Feb 21 15:33:38 2014 +0000
+++ b/mbed.bld	Wed Jul 16 10:30:54 2014 +0000
@@ -1,1 +1,1 @@
-http://mbed.org/users/mbed_official/code/mbed/builds/8e73be2a2ac1
\ No newline at end of file
+http://mbed.org/users/mbed_official/code/mbed/builds/04dd9b1680ae
\ No newline at end of file