QT Chan
/
Nucleo_read_button
Button control led blink
main.cpp
- Committer:
- szqt
- Date:
- 2016-07-03
- Revision:
- 1:03f6bcfaacf8
- Parent:
- 0:c9d8fcdda4d0
File content as of revision 1:03f6bcfaacf8:
#include "mbed.h" DigitalIn mybutton(USER_BUTTON); DigitalOut myled(LED1); int main() { while(1) { if (mybutton == 0) { // Button is pressed myled = !myled; // Toggle the LED state wait(0.1); // 100 ms } else { myled = 1; // LED is ON wait(0.2); // 200 ms myled = 0; // LED is OFF wait(1.0); // 1 sec } } }