joseph chen
/
Nucleo_read_button_interrupt
button trigger interrupt
Diff: main.cpp
- Revision:
- 0:912303e63cbd
- Child:
- 1:19e910fda737
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Fri Feb 21 12:53:03 2014 +0000 @@ -0,0 +1,23 @@ +#include "mbed.h" + +InterruptIn mybutton(USER_BUTTON); +DigitalOut myled(LED1); + +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); + } +}