Dependencies: mbed
Fork of frdmk64_detach by
Diff: main.cpp
- Revision:
- 0:66eebc209a84
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Thu Sep 25 19:11:06 2014 +0000 @@ -0,0 +1,47 @@ +#include "mbed.h" +Ticker ticker; +InterruptIn boton1(SW2); +InterruptIn boton2(SW3); +DigitalOut led1(LED_GREEN); +DigitalOut led2(LED_RED); +Serial pc(USBTX, USBRX); +int x=0; + +void tick() +{ + led1 = !led1; +} + +void bot1() +{ + if (x==0) { + pc.printf("Alarma!\n"); + led1=1; + led2=0; + ticker.detach(); + x=1; + } +} + +void bot2() +{ + if(x==1) { + led2=1; + ticker.attach(&tick,0.4); + pc.printf("De vuelta a la normalidad!\n"); + x=0; + } +} + +int main() +{ + led1 = 1; + led2 = 1; + ticker.attach(&tick, 0.4); + pc.printf("Estado normal!\n"); + boton1.rise(&bot1); + boton2.rise(&bot2); + while(1) { + + } +} \ No newline at end of file