Maurizio Conti
/
accell-FRDMKL25
Using on board MMA8451Q on FRK25
main.cpp@0:5e8c7a36cb58, 2012-10-12 (annotated)
- Committer:
- chris
- Date:
- Fri Oct 12 13:03:56 2012 +0000
- Revision:
- 0:5e8c7a36cb58
- Child:
- 1:bbb4d2753b6b
First commit
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
chris | 0:5e8c7a36cb58 | 1 | #include "mbed.h" |
chris | 0:5e8c7a36cb58 | 2 | |
chris | 0:5e8c7a36cb58 | 3 | Ticker tick; |
chris | 0:5e8c7a36cb58 | 4 | DigitalOut led1(LED_RED); |
chris | 0:5e8c7a36cb58 | 5 | DigitalOut led2(LED_GREEN); |
chris | 0:5e8c7a36cb58 | 6 | |
chris | 0:5e8c7a36cb58 | 7 | void flip() |
chris | 0:5e8c7a36cb58 | 8 | { |
chris | 0:5e8c7a36cb58 | 9 | led2 = !led2; |
chris | 0:5e8c7a36cb58 | 10 | } |
chris | 0:5e8c7a36cb58 | 11 | |
chris | 0:5e8c7a36cb58 | 12 | int main() |
chris | 0:5e8c7a36cb58 | 13 | { |
chris | 0:5e8c7a36cb58 | 14 | tick.attach(&flip, 0.7); // setup ticker to call flip led2 after 0.7 seconds |
chris | 0:5e8c7a36cb58 | 15 | |
chris | 0:5e8c7a36cb58 | 16 | // spin in a main loop. |
chris | 0:5e8c7a36cb58 | 17 | while(1) { |
chris | 0:5e8c7a36cb58 | 18 | led1 = !led1; |
chris | 0:5e8c7a36cb58 | 19 | wait (0.3); // flip led1 every 0.3 seconds |
chris | 0:5e8c7a36cb58 | 20 | } |
chris | 0:5e8c7a36cb58 | 21 | } |