Hello World for InterruptIn
mbed 2 and mbed OS 5
This is an mbed 2 example. For an mbed-os example, please see:
Import programInterruptIn_HelloWorld
Hello World for InterruptIn
Diff: main.cpp
- Revision:
- 0:7a20a6aa1f5e
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Fri Feb 15 15:13:19 2013 +0000 @@ -0,0 +1,17 @@ +#include "mbed.h" + +InterruptIn button(p5); +DigitalOut led(LED1); +DigitalOut flash(LED4); + +void flip() { + led = !led; +} + +int main() { + button.rise(&flip); // attach the address of the flip function to the rising edge + while(1) { // wait around, interrupts will interrupt this! + flash = !flash; + wait(0.25); + } +} \ No newline at end of file