QT Chan
/
Nucleo_read_button
Button control led blink
main.cpp@0:c9d8fcdda4d0, 2014-02-21 (annotated)
- Committer:
- bcostm
- Date:
- Fri Feb 21 12:57:03 2014 +0000
- Revision:
- 0:c9d8fcdda4d0
- Child:
- 1:03f6bcfaacf8
Initial version.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
bcostm | 0:c9d8fcdda4d0 | 1 | #include "mbed.h" |
bcostm | 0:c9d8fcdda4d0 | 2 | |
bcostm | 0:c9d8fcdda4d0 | 3 | DigitalIn mybutton(USER_BUTTON); |
bcostm | 0:c9d8fcdda4d0 | 4 | DigitalOut myled(LED1); |
bcostm | 0:c9d8fcdda4d0 | 5 | |
bcostm | 0:c9d8fcdda4d0 | 6 | int main() { |
bcostm | 0:c9d8fcdda4d0 | 7 | while(1) { |
bcostm | 0:c9d8fcdda4d0 | 8 | if (mybutton == 0) { // Button is pressed |
bcostm | 0:c9d8fcdda4d0 | 9 | myled = !myled; // Toggle the LED state |
bcostm | 0:c9d8fcdda4d0 | 10 | wait(0.2); // 200 ms |
bcostm | 0:c9d8fcdda4d0 | 11 | } |
bcostm | 0:c9d8fcdda4d0 | 12 | } |
bcostm | 0:c9d8fcdda4d0 | 13 | } |
bcostm | 0:c9d8fcdda4d0 | 14 |