ACCELEROMETRO Y LCD

Dependencies:   MMA8451Q mbed TextLCD

Fork of FRDM_MMA8451Q by Freescale

Files at this revision

API Documentation at this revision

Comitter:
mderrant
Date:
Sat Jul 19 02:56:47 2014 +0000
Parent:
8:d797bfa9f76e
Child:
11:fa2577154dfd
Commit message:
ACELEROMETRO Y LCD

Changed in this revision

TextLCD.lib Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/TextLCD.lib	Sat Jul 19 02:56:47 2014 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbeded/code/TextLCD/#c382632a6e27
--- a/main.cpp	Fri Feb 21 15:33:38 2014 +0000
+++ b/main.cpp	Sat Jul 19 02:56:47 2014 +0000
@@ -1,5 +1,10 @@
 #include "mbed.h"
 #include "MMA8451Q.h"
+#include "TextLCD.h"
+
+TextLCD lcd(PTA13, PTD2, PTA4, PTA5, PTC8, PTC9, TextLCD::LCD16x2); // PARA PLACA KL46F
+
+
 
 #if   defined (TARGET_KL25Z) || defined (TARGET_KL46Z)
   PinName const SDA = PTE25;
@@ -13,20 +18,32 @@
 
 #define MMA8451_I2C_ADDRESS (0x1d<<1)
 
+
+int cur;
 int main(void) {
-    MMA8451Q acc(SDA, SCL, MMA8451_I2C_ADDRESS);
+    MMA8451Q acelerometro(SDA, SCL, MMA8451_I2C_ADDRESS);
     PwmOut rled(LED1);
     PwmOut gled(LED2);
     PwmOut bled(LED3);
     
-    printf("MMA8451 ID: %d\n", acc.getWhoAmI());
+//    printf("MMA8451 ID: %d\n", acelerometro.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());
+        x = rled = 1.0 - abs(acelerometro.getAccX());
+        y = gled = 1.0 - abs(acelerometro.getAccY());
+        z = bled = 1.0 - abs(acelerometro.getAccZ());
         wait(0.1);
-        printf("X: %1.2f, Y: %1.2f, Z: %1.2f\n", x, y, z);
+ //       printf("X: %1.4f, Y: %1.4f, Z: %1.4f \n\r", x, y, z);
+           
+         lcd.clear();
+         lcd.setCursor(cur,0);
+         lcd.printf("  X   Y   Z" );
+          lcd.setCursor(0,1); 
+         lcd.printf("%1.2f, %1.2f, %1.2f", x, y, z);
+         
+        
+        
+        
     }
 }