![](/media/cache/profiles/53015ad3b6bbbf80a4d107e6ef603b1e.jpg.50x50_q85.jpg)
acelerometro y LCD
Dependencies: MMA8451Q TextLCD mbed
Fork of FRDM_MMA8451Q by
main.cpp@8:a2b340994747, 2013-12-10 (annotated)
- Committer:
- amarincan
- Date:
- Tue Dec 10 19:26:21 2013 +0000
- Revision:
- 8:a2b340994747
- Parent:
- 5:bf5becf7469c
acelerometro interno de la tarjeta integrado a un LCD
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
chris | 2:41db78380a6e | 1 | #include "mbed.h" |
chris | 2:41db78380a6e | 2 | #include "MMA8451Q.h" |
amarincan | 8:a2b340994747 | 3 | #include "TextLCD.h" |
chris | 2:41db78380a6e | 4 | |
chris | 2:41db78380a6e | 5 | #define MMA8451_I2C_ADDRESS (0x1d<<1) |
chris | 2:41db78380a6e | 6 | |
amarincan | 8:a2b340994747 | 7 | TextLCD lcd(PTB10, PTB11, PTE2, PTE3, PTE4, PTE5); // rs, e, d4-d7 |
amarincan | 8:a2b340994747 | 8 | float acx=0,acy=0,acz=0; |
amarincan | 8:a2b340994747 | 9 | |
chris | 4:367de1084ea9 | 10 | int main(void) { |
emilmont | 5:bf5becf7469c | 11 | MMA8451Q acc(PTE25, PTE24, MMA8451_I2C_ADDRESS); |
emilmont | 5:bf5becf7469c | 12 | PwmOut rled(LED_RED); |
emilmont | 5:bf5becf7469c | 13 | PwmOut gled(LED_GREEN); |
emilmont | 5:bf5becf7469c | 14 | PwmOut bled(LED_BLUE); |
amarincan | 8:a2b340994747 | 15 | lcd.printf("Acelerometro"); |
amarincan | 8:a2b340994747 | 16 | wait(2); |
amarincan | 8:a2b340994747 | 17 | lcd.locate(0,0); |
amarincan | 8:a2b340994747 | 18 | lcd.printf("acx=0 acy=0"); |
amarincan | 8:a2b340994747 | 19 | lcd.locate(0,1); |
amarincan | 8:a2b340994747 | 20 | lcd.printf("acz=0 "); |
emilmont | 5:bf5becf7469c | 21 | while (true) { |
chris | 3:f2d3e041d8f2 | 22 | rled = 1.0 - abs(acc.getAccX()); |
amarincan | 8:a2b340994747 | 23 | acx=1.0 - abs(acc.getAccX()); |
chris | 3:f2d3e041d8f2 | 24 | gled = 1.0 - abs(acc.getAccY()); |
amarincan | 8:a2b340994747 | 25 | acy=1.0 - abs(acc.getAccY()); |
chris | 3:f2d3e041d8f2 | 26 | bled = 1.0 - abs(acc.getAccZ()); |
amarincan | 8:a2b340994747 | 27 | acz=1.0 - abs(acc.getAccZ()); |
amarincan | 8:a2b340994747 | 28 | |
amarincan | 8:a2b340994747 | 29 | lcd.locate(4,0); |
amarincan | 8:a2b340994747 | 30 | lcd.printf(" "); |
amarincan | 8:a2b340994747 | 31 | lcd.locate(4,0); |
amarincan | 8:a2b340994747 | 32 | lcd.printf("%1.2f",acx); |
amarincan | 8:a2b340994747 | 33 | lcd.locate(12,0); |
amarincan | 8:a2b340994747 | 34 | lcd.printf(" "); |
amarincan | 8:a2b340994747 | 35 | lcd.locate(12,0); |
amarincan | 8:a2b340994747 | 36 | lcd.printf("%1.2f",acy); |
amarincan | 8:a2b340994747 | 37 | lcd.locate(4,1); |
amarincan | 8:a2b340994747 | 38 | lcd.printf(" "); |
amarincan | 8:a2b340994747 | 39 | lcd.locate(4,1); |
amarincan | 8:a2b340994747 | 40 | lcd.printf("%1.2f",acz); |
amarincan | 8:a2b340994747 | 41 | wait(0.2); |
chris | 2:41db78380a6e | 42 | } |
chris | 2:41db78380a6e | 43 | } |