Wilmar Cr
/
TAREA8-ACELEROMETRO
Acelerómetro integrado en la tarjeta, se visualiza las coordenadas X, Y y Z en una pantalla LCD 16x2.
Revision 0:a77e50ca84d1, committed 2013-12-13
- Comitter:
- Wilmar87
- Date:
- Fri Dec 13 04:34:39 2013 +0000
- Commit message:
- yes;
Changed in this revision
diff -r 000000000000 -r a77e50ca84d1 MMA8451Q.lib --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/MMA8451Q.lib Fri Dec 13 04:34:39 2013 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/JoKer/code/MMA8451Q/#2d14600116fc
diff -r 000000000000 -r a77e50ca84d1 TextLCD.lib --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/TextLCD.lib Fri Dec 13 04:34:39 2013 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/Wilmar87/code/TextLCD4/#8e4a9cbc6c16
diff -r 000000000000 -r a77e50ca84d1 main.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Fri Dec 13 04:34:39 2013 +0000 @@ -0,0 +1,55 @@ +#include "mbed.h" +#include "MMA8451Q.h" +#include "TextLCD.h" +#define MMA8451_I2C_ADDRESS (0x1d<<1) + +TextLCD lcd(PTB10, PTB11, PTE2, PTE3, PTE4, PTE5); //------Puertos LCD rs, e, d4, d5, d6, d7 + + + //Códigos LCD +int C1=0x0E; //------ Muestra el cursor + +float x, y, z; //----- Coordenadas + +int main(void) { +MMA8451Q acc(PTE25, PTE24, MMA8451_I2C_ADDRESS); +PwmOut led1(LED1); +PwmOut led2(LED2); +PwmOut led3(LED3); + + led1=led2=led3=1; + lcd.printf("**ACELEROMETRO**"); + wait(1.5); + lcd.cls(); + + //lcd.writeCommand(C1);//comando para mostrar el cursor en el LCD + lcd.locate(4,0); // Ubica e imprime nombre de las variables en la LCD + lcd.printf("EX="); + lcd.locate(0,1); + lcd.printf("EY="); + lcd.locate(9,1); + lcd.printf("EZ="); + wait(2); + + while(1) { + + x=led1 = 1.0 - abs(acc.getAccX()); + y=led2 = 1.0 - abs(acc.getAccY()); + z=led3 = 1.0 - abs(acc.getAccZ()); + + lcd.locate(6,0); + lcd.printf(" "); + lcd.locate(4,0); + lcd.printf("EX=%0.2f",x); + lcd.locate(2,1); + lcd.printf(" "); + lcd.locate(0,1); + lcd.printf("EY=%0.2f",y); + lcd.locate(11,1); + lcd.printf(" "); + lcd.locate(9,1); + lcd.printf("EZ=%0.2f",z); + wait(0.1); + } + } +
diff -r 000000000000 -r a77e50ca84d1 mbed.bld --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Fri Dec 13 04:34:39 2013 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/mbed/builds/1efda918f0ba \ No newline at end of file