Acelerometro
Dependencies: MMA8451Q TextLCD mbed
main.cpp@0:89e2fbe7492b, 2013-12-12 (annotated)
- Committer:
- leorestrepo93
- Date:
- Thu Dec 12 13:45:24 2013 +0000
- Revision:
- 0:89e2fbe7492b
Acelerometro
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
leorestrepo93 | 0:89e2fbe7492b | 1 | #include "mbed.h" |
leorestrepo93 | 0:89e2fbe7492b | 2 | #include "MMA8451Q.h" |
leorestrepo93 | 0:89e2fbe7492b | 3 | #include "TextLCD.h" |
leorestrepo93 | 0:89e2fbe7492b | 4 | #define MMA8451_I2C_ADDRESS (0x1d<<1) |
leorestrepo93 | 0:89e2fbe7492b | 5 | |
leorestrepo93 | 0:89e2fbe7492b | 6 | |
leorestrepo93 | 0:89e2fbe7492b | 7 | |
leorestrepo93 | 0:89e2fbe7492b | 8 | |
leorestrepo93 | 0:89e2fbe7492b | 9 | |
leorestrepo93 | 0:89e2fbe7492b | 10 | TextLCD lcd(PTB10,PTB11,PTE2,PTE3,PTE4,PTE5); |
leorestrepo93 | 0:89e2fbe7492b | 11 | |
leorestrepo93 | 0:89e2fbe7492b | 12 | MMA8451Q acc(PTE25, PTE24, MMA8451_I2C_ADDRESS); |
leorestrepo93 | 0:89e2fbe7492b | 13 | |
leorestrepo93 | 0:89e2fbe7492b | 14 | float sensor_data[3]; |
leorestrepo93 | 0:89e2fbe7492b | 15 | |
leorestrepo93 | 0:89e2fbe7492b | 16 | int main(){ |
leorestrepo93 | 0:89e2fbe7492b | 17 | lcd.locate(0,0); |
leorestrepo93 | 0:89e2fbe7492b | 18 | lcd.printf("Tarea Acelerometro"); |
leorestrepo93 | 0:89e2fbe7492b | 19 | wait(2); |
leorestrepo93 | 0:89e2fbe7492b | 20 | lcd.cls(); |
leorestrepo93 | 0:89e2fbe7492b | 21 | lcd.locate(0,0); |
leorestrepo93 | 0:89e2fbe7492b | 22 | lcd.printf("X:"); |
leorestrepo93 | 0:89e2fbe7492b | 23 | lcd.locate(7,0); |
leorestrepo93 | 0:89e2fbe7492b | 24 | lcd.printf("Y:"); |
leorestrepo93 | 0:89e2fbe7492b | 25 | lcd.locate(3,1); |
leorestrepo93 | 0:89e2fbe7492b | 26 | lcd.printf("Z:"); |
leorestrepo93 | 0:89e2fbe7492b | 27 | while(1){ |
leorestrepo93 | 0:89e2fbe7492b | 28 | |
leorestrepo93 | 0:89e2fbe7492b | 29 | acc.getAccAllAxis( &sensor_data[0]); |
leorestrepo93 | 0:89e2fbe7492b | 30 | lcd.locate(2,0); |
leorestrepo93 | 0:89e2fbe7492b | 31 | lcd.printf(" "); |
leorestrepo93 | 0:89e2fbe7492b | 32 | lcd.locate(2,0); |
leorestrepo93 | 0:89e2fbe7492b | 33 | lcd.printf("%.2f",sensor_data[2]); |
leorestrepo93 | 0:89e2fbe7492b | 34 | lcd.locate(9,0); |
leorestrepo93 | 0:89e2fbe7492b | 35 | lcd.printf(" "); |
leorestrepo93 | 0:89e2fbe7492b | 36 | lcd.locate(9,0); |
leorestrepo93 | 0:89e2fbe7492b | 37 | lcd.printf("%.2f",sensor_data[0]); |
leorestrepo93 | 0:89e2fbe7492b | 38 | lcd.locate(5,1); |
leorestrepo93 | 0:89e2fbe7492b | 39 | lcd.printf(" "); |
leorestrepo93 | 0:89e2fbe7492b | 40 | lcd.locate(5,1); |
leorestrepo93 | 0:89e2fbe7492b | 41 | lcd.printf("%.2f",sensor_data[1]); |
leorestrepo93 | 0:89e2fbe7492b | 42 | wait(1); |
leorestrepo93 | 0:89e2fbe7492b | 43 | |
leorestrepo93 | 0:89e2fbe7492b | 44 | } |
leorestrepo93 | 0:89e2fbe7492b | 45 | |
leorestrepo93 | 0:89e2fbe7492b | 46 | |
leorestrepo93 | 0:89e2fbe7492b | 47 | } |