Accelerometro + LCD

Dependencies:   MMA8451Q TextLCD mbed

Files at this revision

API Documentation at this revision

Comitter:
avallejopo
Date:
Fri Nov 29 18:28:16 2013 +0000
Commit message:
Accelerometro + LCD

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	Fri Nov 29 18:28:16 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	Fri Nov 29 18:28:16 2013 +0000
@@ -0,0 +1,1 @@
+https://mbed.org/users/avallejopo/code/TextLCD/#aba8ab3dde9d
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Fri Nov 29 18:28:16 2013 +0000
@@ -0,0 +1,26 @@
+#include "mbed.h"
+#include "MMA8451Q.h"
+#include "TextLCD.h"
+#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);
+    PwmOut rled(LED_RED);
+    PwmOut gled(LED_GREEN);
+    PwmOut bled(LED_BLUE);
+ 
+    while (true) {
+        lcd.locate(0,0);lcd.printf("      ");
+        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());
+        gled = 1.0 - abs(acc.getAccY());
+        bled = 1.0 - abs(acc.getAccZ());
+        wait(0.3);
+    }
+}
+ 
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Fri Nov 29 18:28:16 2013 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/a9913a65894f
\ No newline at end of file