![](/media/cache/group/NXP_logo_RGB_web.png.50x50_q85.jpg)
frdm ticker example for the Freescale freedom platform
Dependencies: mbed
Fork of frdm_ticker by
main.cpp@1:bbb4d2753b6b, 2012-10-12 (annotated)
- Committer:
- chris
- Date:
- Fri Oct 12 14:55:55 2012 +0000
- Revision:
- 1:bbb4d2753b6b
- Parent:
- 0:5e8c7a36cb58
- Child:
- 2:b085bc47e75b
Ticker example for FRDM-KL25Z
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 | 1:bbb4d2753b6b | 21 | } |