通过按键控制LED
Dependencies: mbed
main.cpp@0:c3898039eff5, 2015-12-05 (annotated)
- Committer:
- Andthen
- Date:
- Sat Dec 05 03:27:57 2015 +0000
- Revision:
- 0:c3898039eff5
mbed???????
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Andthen | 0:c3898039eff5 | 1 | #include "mbed.h" |
Andthen | 0:c3898039eff5 | 2 | DigitalOut led1(LED1); |
Andthen | 0:c3898039eff5 | 3 | DigitalIn btn(USER_BUTTON); |
Andthen | 0:c3898039eff5 | 4 | int main() |
Andthen | 0:c3898039eff5 | 5 | { |
Andthen | 0:c3898039eff5 | 6 | led1=0; |
Andthen | 0:c3898039eff5 | 7 | while (1) { |
Andthen | 0:c3898039eff5 | 8 | if (btn==0 ) { |
Andthen | 0:c3898039eff5 | 9 | wait_ms(10); |
Andthen | 0:c3898039eff5 | 10 | if (btn==0 ) { |
Andthen | 0:c3898039eff5 | 11 | led1=!led1; |
Andthen | 0:c3898039eff5 | 12 | while (btn==0); |
Andthen | 0:c3898039eff5 | 13 | } |
Andthen | 0:c3898039eff5 | 14 | } |
Andthen | 0:c3898039eff5 | 15 | |
Andthen | 0:c3898039eff5 | 16 | } |
Andthen | 0:c3898039eff5 | 17 | |
Andthen | 0:c3898039eff5 | 18 | |
Andthen | 0:c3898039eff5 | 19 | } |