Combinación de color de los led en base a la posición de la tarjeta
Dependencies: MMA8451Q TextLCD mbed
Revision 0:0fe97547ca93, committed 2013-12-11
- Comitter:
- ikortegag
- Date:
- Wed Dec 11 23:04:29 2013 +0000
- Commit message:
- Combinaci?n de color de los led en base a la posici?n de la tarjeta
Changed in this revision
diff -r 000000000000 -r 0fe97547ca93 MMA8451Q.lib --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/MMA8451Q.lib Wed Dec 11 23:04:29 2013 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/JoKer/code/MMA8451Q/#2d14600116fc
diff -r 000000000000 -r 0fe97547ca93 TextLCD.lib --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/TextLCD.lib Wed Dec 11 23:04:29 2013 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/simon/code/TextLCD/#44f34c09bd37
diff -r 000000000000 -r 0fe97547ca93 main.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Wed Dec 11 23:04:29 2013 +0000 @@ -0,0 +1,32 @@ +#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); // Declaración de los led's PWM, para poder variar la intensidad del led + PwmOut gled(LED_GREEN); + PwmOut bled(LED_BLUE); + + while (true) { + rled = 1.0 - abs(acc.getAccX()); // Asignar la coordenada de la tarjeta + gled = 1.0 - abs(acc.getAccY()); + bled = 1.0 - abs(acc.getAccZ()); + lcd.locate(0,0);// Asignación de las posiciones de la pantalla lcd + lcd.printf(" "); + lcd.locate(0,0); + lcd.printf("X=%g",acc.getAccX()); + lcd.locate(8,0); + lcd.printf(" "); // para una coordenada más pequeña no aparezca en la pantalla + 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()); + + wait(0.3); + } +} \ No newline at end of file
diff -r 000000000000 -r 0fe97547ca93 mbed.bld --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Wed Dec 11 23:04:29 2013 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/mbed/builds/a9913a65894f \ No newline at end of file