Gerardo Carmona
/
info_interrupts
Diff: main.cpp
- Revision:
- 0:d10d1e4ecd6b
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Fri May 09 15:34:11 2014 +0000 @@ -0,0 +1,26 @@ +/* + On KL25Z interrupts only works on ports A and D + Options are: raise and fall +*/ + +#include "mbed.h" + +InterruptIn button(PTD4); //D3 +DigitalOut led(LED1); +DigitalOut flash(LED3); + + +void flip(); + +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); + } +} + +void flip() { + led = !led; +} \ No newline at end of file