Acelerometro
Dependencies: MMA8451Q TextLCD mbed
Diff: main.cpp
- Revision:
- 0:89e2fbe7492b
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Thu Dec 12 13:45:24 2013 +0000 @@ -0,0 +1,47 @@ +#include "mbed.h" +#include "MMA8451Q.h" +#include "TextLCD.h" +#define MMA8451_I2C_ADDRESS (0x1d<<1) + + + + + +TextLCD lcd(PTB10,PTB11,PTE2,PTE3,PTE4,PTE5); + +MMA8451Q acc(PTE25, PTE24, MMA8451_I2C_ADDRESS); + +float sensor_data[3]; + +int main(){ + lcd.locate(0,0); + lcd.printf("Tarea Acelerometro"); + wait(2); + lcd.cls(); + lcd.locate(0,0); + lcd.printf("X:"); + lcd.locate(7,0); + lcd.printf("Y:"); + lcd.locate(3,1); + lcd.printf("Z:"); + while(1){ + + acc.getAccAllAxis( &sensor_data[0]); + lcd.locate(2,0); + lcd.printf(" "); + lcd.locate(2,0); + lcd.printf("%.2f",sensor_data[2]); + lcd.locate(9,0); + lcd.printf(" "); + lcd.locate(9,0); + lcd.printf("%.2f",sensor_data[0]); + lcd.locate(5,1); + lcd.printf(" "); + lcd.locate(5,1); + lcd.printf("%.2f",sensor_data[1]); + wait(1); + + } + + +} \ No newline at end of file