Reads the KL25Z accelerometer values and sends them to the serial port. RGB LED changes color accordingly.

Dependencies:   MMA8451Q mbed

Fork of FRDM_MMA8451Q by mbed official

Files at this revision

API Documentation at this revision

Comitter:
lmsousa
Date:
Thu May 07 10:00:52 2015 +0000
Parent:
7:70775be9f474
Commit message:
Sends the KL25Z acelerometer values to the serial port. Fixed some issues with serial messages.

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
diff -r 70775be9f474 -r 264bba6d39ee main.cpp
--- a/main.cpp	Tue Feb 19 23:46:45 2013 +0000
+++ b/main.cpp	Thu May 07 10:00:52 2015 +0000
@@ -2,17 +2,25 @@
 #include "MMA8451Q.h"
 
 #define MMA8451_I2C_ADDRESS (0x1d<<1)
-
-int main(void) {
+Serial pc(USBTX, USBRX);
+int main(void)
+{
+    pc.baud(9600);
     MMA8451Q acc(PTE25, PTE24, MMA8451_I2C_ADDRESS);
     PwmOut rled(LED_RED);
     PwmOut gled(LED_GREEN);
     PwmOut bled(LED_BLUE);
 
     while (true) {
+        pc.printf("X= %g \n\r",acc.getAccX());
         rled = 1.0 - abs(acc.getAccX());
+
+        pc.printf("Y= %g \n\r",acc.getAccY());
         gled = 1.0 - abs(acc.getAccY());
+
+        pc.printf("Z= %g \n\n\r",acc.getAccZ());
         bled = 1.0 - abs(acc.getAccZ());
-        wait(0.1);
+        wait(1);
+        
     }
 }