wang tang
/
LED3
LED and button system3
Fork of LED2 by
main.cpp@5:26c21c978f66, 2017-10-20 (annotated)
- Committer:
- e58136782000
- Date:
- Fri Oct 20 07:36:29 2017 +0000
- Revision:
- 5:26c21c978f66
- Parent:
- 4:afd407e92a89
LED and button 3:; on: blinky; off: led1 on
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
rozendhyan | 0:6e75cf3220cb | 1 | #include "mbed.h" |
rozendhyan | 0:6e75cf3220cb | 2 | |
rozendhyan | 0:6e75cf3220cb | 3 | DigitalOut led1(D4); |
rozendhyan | 0:6e75cf3220cb | 4 | DigitalOut led2(D5); |
rozendhyan | 0:6e75cf3220cb | 5 | DigitalOut led3(D6); |
e58136782000 | 1:59cafc988b1c | 6 | DigitalIn button(D7); |
rozendhyan | 0:6e75cf3220cb | 7 | void LED_Blinkly(DigitalOut led1,DigitalOut led2,DigitalOut led3); |
rozendhyan | 0:6e75cf3220cb | 8 | // main() runs in its own thread in the OS |
e58136782000 | 1:59cafc988b1c | 9 | int main() |
e58136782000 | 1:59cafc988b1c | 10 | { |
e58136782000 | 1:59cafc988b1c | 11 | while(1) |
e58136782000 | 1:59cafc988b1c | 12 | { |
e58136782000 | 1:59cafc988b1c | 13 | |
e58136782000 | 5:26c21c978f66 | 14 | if(button == true) |
e58136782000 | 1:59cafc988b1c | 15 | { |
e58136782000 | 1:59cafc988b1c | 16 | led1 =! led1; |
e58136782000 | 1:59cafc988b1c | 17 | wait(0.5); |
e58136782000 | 1:59cafc988b1c | 18 | led2 =! led2; |
e58136782000 | 1:59cafc988b1c | 19 | wait(0.5); |
e58136782000 | 1:59cafc988b1c | 20 | led3 =! led3; |
e58136782000 | 1:59cafc988b1c | 21 | wait(0.5); |
e58136782000 | 1:59cafc988b1c | 22 | } |
e58136782000 | 1:59cafc988b1c | 23 | else |
e58136782000 | 1:59cafc988b1c | 24 | { |
e58136782000 | 5:26c21c978f66 | 25 | led1 = true; |
e58136782000 | 1:59cafc988b1c | 26 | led2 = false; |
e58136782000 | 1:59cafc988b1c | 27 | led3 = false; |
e58136782000 | 1:59cafc988b1c | 28 | } |
e58136782000 | 1:59cafc988b1c | 29 | } |
e58136782000 | 1:59cafc988b1c | 30 | } |