Use the button on Nucleo board in Interrupt mode
Diff: main.cpp
- Revision:
- 0:1b77c1ffae11
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Mon Dec 28 23:04:25 2015 +0000 @@ -0,0 +1,29 @@ +#include "mbed.h" + +DigitalOut myled(LED1); +InterruptIn mybutton(USER_BUTTON); + +float delay = 1.0; // 1 sec + +void pressed() +{ + if (delay == 1.0) + { + delay = 0.2; // 200 ms + } + else + { + delay = 1.0; // 1 sec + } +} + +int main() +{ + mybutton.fall(&pressed); + + while (1) + { + myled = !myled; + wait(delay); + } +}