Programa para dejar prendido o apagado un led mediante un boton haciendo uso de subrutinas en las interrupciones

Dependencies:   mbed

main.cpp

Committer:
rcortes
Date:
2014-03-18
Revision:
0:f0bc7bd8ae33

File content as of revision 0:f0bc7bd8ae33:

//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!
    }
}