![](/media/cache/profiles/DalekSelfie2.jpg.50x50_q85.jpg)
FRDM-KL25Z with Nokia 3110 type LCD display Using accelerometer to make movements
Dependencies: MMA8451Q N3310LCD mbed
Fork of FRDM_MMA8451Q by
main.cpp@0:d9c1551e1fdc, 2012-10-11 (annotated)
- Committer:
- emilmont
- Date:
- Thu Oct 11 10:56:33 2012 +0000
- Revision:
- 0:d9c1551e1fdc
- Child:
- 2:41db78380a6e
Freedom board accelerometer example
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
emilmont | 0:d9c1551e1fdc | 1 | #include "mbed.h" |
emilmont | 0:d9c1551e1fdc | 2 | #include "MMA8451Q.h" |
emilmont | 0:d9c1551e1fdc | 3 | |
emilmont | 0:d9c1551e1fdc | 4 | #define MMA8451_I2C_ADDRESS (0x1d<<1) |
emilmont | 0:d9c1551e1fdc | 5 | |
emilmont | 0:d9c1551e1fdc | 6 | int main(void) { |
emilmont | 0:d9c1551e1fdc | 7 | DigitalOut led(LED_GREEN); |
emilmont | 0:d9c1551e1fdc | 8 | MMA8451Q acc(P_E25, P_E24, MMA8451_I2C_ADDRESS); |
emilmont | 0:d9c1551e1fdc | 9 | printf("WHO AM I: 0x%2X\r\n", acc.getWhoAmI()); |
emilmont | 0:d9c1551e1fdc | 10 | |
emilmont | 0:d9c1551e1fdc | 11 | while (true) { |
emilmont | 0:d9c1551e1fdc | 12 | printf("-----------\r\n"); |
emilmont | 0:d9c1551e1fdc | 13 | printf("acc_x: %d\r\n", acc.getAccX()); |
emilmont | 0:d9c1551e1fdc | 14 | printf("acc_y: %d\r\n", acc.getAccY()); |
emilmont | 0:d9c1551e1fdc | 15 | printf("acc_z: %d\r\n", acc.getAccZ()); |
emilmont | 0:d9c1551e1fdc | 16 | |
emilmont | 0:d9c1551e1fdc | 17 | wait(1); |
emilmont | 0:d9c1551e1fdc | 18 | led = !led; |
emilmont | 0:d9c1551e1fdc | 19 | } |
emilmont | 0:d9c1551e1fdc | 20 | } |