Ted Lin
/
Nucleo_key_led_with_timeout
implement button press/release with double check using fall/rise & timeout
main.cpp@0:6a3454713c54, 2016-03-06 (annotated)
- Committer:
- mintisan
- Date:
- Sun Mar 06 04:25:10 2016 +0000
- Revision:
- 0:6a3454713c54
- Child:
- 1:63744318c4d7
control LED via KEY
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
mintisan | 0:6a3454713c54 | 1 | #include "mbed.h" |
mintisan | 0:6a3454713c54 | 2 | |
mintisan | 0:6a3454713c54 | 3 | DigitalIn mybutton(PC_13); |
mintisan | 0:6a3454713c54 | 4 | DigitalOut myled(PA_5); |
mintisan | 0:6a3454713c54 | 5 | |
mintisan | 0:6a3454713c54 | 6 | int main(void) |
mintisan | 0:6a3454713c54 | 7 | { |
mintisan | 0:6a3454713c54 | 8 | while(1) { |
mintisan | 0:6a3454713c54 | 9 | if(mybutton == 0) { |
mintisan | 0:6a3454713c54 | 10 | myled = 1; // button pressed |
mintisan | 0:6a3454713c54 | 11 | } else { |
mintisan | 0:6a3454713c54 | 12 | myled = 0; // button released |
mintisan | 0:6a3454713c54 | 13 | } |
mintisan | 0:6a3454713c54 | 14 | } |
mintisan | 0:6a3454713c54 | 15 | } |