Luca Mottola
/
AthensFall19-DISCO-ButtonInterrupt
Example using the user button on DISCO L475E IOT01, using interrupts
Diff: main.cpp
- Revision:
- 0:fc82b2d5fe07
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Thu Nov 08 17:09:25 2018 +0000 @@ -0,0 +1,17 @@ +#include "mbed.h" + +InterruptIn button(USER_BUTTON); +DigitalOut led(LED1); +DigitalOut heartbeat(LED2); + +void toggle() { + led = !led; +} + +int main() { + button.rise(&toggle); // Call toggle function on the rising edge + while(1) { // Wait around, interrupts will interrupt this! + heartbeat = !heartbeat; + wait(0.25); + } +}