Accelerometro + LCD
Dependencies: MMA8451Q TextLCD mbed
Revision 0:f864f36d0da6, committed 2013-11-29
- Comitter:
- avallejopo
- Date:
- Fri Nov 29 18:28:16 2013 +0000
- Commit message:
- Accelerometro + LCD
Changed in this revision
diff -r 000000000000 -r f864f36d0da6 MMA8451Q.lib --- /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
diff -r 000000000000 -r f864f36d0da6 TextLCD.lib --- /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
diff -r 000000000000 -r f864f36d0da6 main.cpp --- /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
diff -r 000000000000 -r f864f36d0da6 mbed.bld --- /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