Example using LED and push button
Fork of mbed-os-example-mbed5-blinky by
Diff: main.cpp
- Revision:
- 42:ee570b89946e
- Parent:
- 29:0b58d21e87d6
--- a/main.cpp Tue Jul 18 09:45:02 2017 +0100 +++ b/main.cpp Thu Oct 12 04:56:34 2017 +0000 @@ -1,12 +1,17 @@ #include "mbed.h" - -DigitalOut led1(LED1); - -// main() runs in its own thread in the OS + +InterruptIn enable(D0); //Button active LOW +DigitalOut led(D1); +DigitalOut flash(D2); +void flip() { + led = !led; +} + int main() { - while (true) { - led1 = !led1; - wait(0.5); + enable.rise(&flip); // attach the address of the flip function to the rising edge + while(1) { // wait around, interrupts will interrupt this! + flash = !flash; + wait(5); } + } -