This example shows how to use interruptions to simply turn on/off a led.
Fork of mbed-os-example-mbed5-blinky by
Revision 64:e5a8e29c82de, committed 2018-03-26
- Comitter:
- jsquiroga
- Date:
- Mon Mar 26 19:04:06 2018 -0500
- Parent:
- 63:5ad45d9461da
- Commit message:
- final
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
diff -r 5ad45d9461da -r e5a8e29c82de main.cpp --- a/main.cpp Mon Mar 26 23:48:29 2018 +0000 +++ b/main.cpp Mon Mar 26 19:04:06 2018 -0500 @@ -1,12 +1,33 @@ -#include "mbed.h" +#include "mbed.h" -DigitalOut led1(LED1); + +//Define outputs + +DigitalOut blue(LED3); + + +//Define interrupt inputs + + InterruptIn button(SW2); //interrupcion para el boton 2 + + +void BlinkLed (){ + blue=!blue; + } -// main() runs in its own thread in the OS -int main() { - while (true) { - led1 = !led1; - wait(0.5); + +int main() +{ + __enable_irq(); //Enable Interrupts + + blue=0; //initialize output + + button.rise(&BlinkLed); //The ISR activates with rising edge of button and activate the function. + + + while(1) + { + // Write your code + } -} - +} \ No newline at end of file