blink led2 every 5 seconds.
Fork of LED_blink_at_5second_wiznxt by
main.cpp@1:20da5e3d89e7, 2014-10-19 (annotated)
- Committer:
- mrsoundhar
- Date:
- Sun Oct 19 07:50:07 2014 +0000
- Revision:
- 1:20da5e3d89e7
- Parent:
- 0:4a11c98a6810
test
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| wiznxt | 0:4a11c98a6810 | 1 | #include "mbed.h" |
| wiznxt | 0:4a11c98a6810 | 2 | |
| wiznxt | 0:4a11c98a6810 | 3 | Timeout timeout; |
| mrsoundhar | 1:20da5e3d89e7 | 4 | DigitalOut led1(LED3); |
| wiznxt | 0:4a11c98a6810 | 5 | DigitalOut led2(LED2); |
| wiznxt | 0:4a11c98a6810 | 6 | int on = 1; |
| wiznxt | 0:4a11c98a6810 | 7 | void attimeout() { |
| wiznxt | 0:4a11c98a6810 | 8 | on = 1; |
| wiznxt | 0:4a11c98a6810 | 9 | led2 = !led2; |
| wiznxt | 0:4a11c98a6810 | 10 | } |
| wiznxt | 0:4a11c98a6810 | 11 | int main() { |
| wiznxt | 0:4a11c98a6810 | 12 | while (1) { |
| wiznxt | 0:4a11c98a6810 | 13 | if (on) { |
| wiznxt | 0:4a11c98a6810 | 14 | timeout.attach(&attimeout, 5); |
| wiznxt | 0:4a11c98a6810 | 15 | on = 0; |
| wiznxt | 0:4a11c98a6810 | 16 | } |
| wiznxt | 0:4a11c98a6810 | 17 | led1 = 1; |
| wiznxt | 0:4a11c98a6810 | 18 | wait(0.5); |
| wiznxt | 0:4a11c98a6810 | 19 | led1 = 0; |
| wiznxt | 0:4a11c98a6810 | 20 | wait(0.5); |
| wiznxt | 0:4a11c98a6810 | 21 | } |
| wiznxt | 0:4a11c98a6810 | 22 | } |
