tarea alarma

Dependencies:   mbed

Fork of frdmk64_detach by IPN ESIME ZACATENCO

main.cpp

Committer:
ArlesValdovinos
Date:
2014-09-25
Revision:
0:66eebc209a84

File content as of revision 0:66eebc209a84:

#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) {

    }
}