Programa para dejar prendido o apagado un led mediante un boton haciendo uso de subrutinas en las interrupciones
Diff: main.cpp
- Revision:
- 0:f0bc7bd8ae33
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Tue Mar 18 00:44:32 2014 +0000 @@ -0,0 +1,27 @@ +//Programa para dejar prendido o apagado un led mediante un boton +//Haciendo uso de subrutinas en las interrupciones +//Y sin usar el programa principal +#include "mbed.h" +InterruptIn sw1(SW1); +InterruptIn sw3(SW3); + +DigitalOut led_rojo(LED_RED); +DigitalOut led_verde(LED_GREEN); + +void sw1_int() +{ + led_rojo = !led_rojo; +} +void sw3_int() +{ + led_verde = !led_verde; +} +int main() +{ + led_rojo=1; + led_verde=1; + sw1.fall(&sw1_int); // attach the address of the function to the falling edge + sw3.fall(&sw3_int); // attach the address of the function to the falling edge + while(1) { // wait around, interrupts will interrupt this! + } +}