Acelerómetro: This program shows the coordinate axis (X,Y,Z) when you move the card FRDM KL25Z in all the directions

Dependencies:   MMA8451Q TextLCD mbed

Files at this revision

API Documentation at this revision

Comitter:
lcorralesc1
Date:
Sun Dec 15 15:24:46 2013 +0000
Commit message:
Aceler?metro: This program shows the coordinate axis (X,Y,Z) when you move the card FRDM KL25Z in all the directions

Changed in this revision

MMA8451Q.lib Show annotated file Show diff for this revision Revisions of this file
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
mbed.bld Show annotated file Show diff for this revision Revisions of this file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/MMA8451Q.lib	Sun Dec 15 15:24:46 2013 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/JoKer/code/MMA8451Q/#2d14600116fc
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/TextLCD.lib	Sun Dec 15 15:24:46 2013 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/simon/code/TextLCD/#44f34c09bd37
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Sun Dec 15 15:24:46 2013 +0000
@@ -0,0 +1,27 @@
+#include "mbed.h"
+#include "MMA8451Q.h" // libreria del acelerometro
+#include "TextLCD.h"0
+#define MMA8451_I2C_ADDRESS (0x1d<<1) 
+ 
+int main(void) {
+    TextLCD lcd(PTB10, PTB11, PTE2, PTE3, PTE4, PTE5); // rs, e, d4-d7
+    MMA8451Q acc(PTE25, PTE24, MMA8451_I2C_ADDRESS); // puerto del acelerometro
+    PwmOut rled(LED_RED); // se declara como PWM para  la asignacion de valores intermedios
+    PwmOut gled(LED_GREEN);
+    PwmOut bled(LED_BLUE);
+ 
+    while (true) {
+        lcd.locate(0,0);lcd.printf("      "); // Posiciones de las pantallas
+        lcd.locate(0,0);lcd.printf("X=%g",acc.getAccX());// 
+        lcd.locate(8,0);lcd.printf("    ");
+        lcd.locate(8,0);lcd.printf("Y=%g",acc.getAccY());
+        lcd.locate(0,1);lcd.printf("    ");
+        lcd.locate(0,1);lcd.printf("Z=%g",acc.getAccZ());
+        rled = 1.0 - abs(acc.getAccX());// obtención de las coordenadas
+        gled = 1.0 - abs(acc.getAccY());// obtención de las coordenadas
+        bled = 1.0 - abs(acc.getAccZ());// obtención de las coordenadas
+        
+        wait(0.3);
+    }
+}
+ 
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Sun Dec 15 15:24:46 2013 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/a9913a65894f
\ No newline at end of file