Manejo de interrupciones para lectura de senal analoga.

Dependencies:   mbed

main.cpp

Committer:
javierdavid2006
Date:
2020-02-08
Revision:
0:fe729db7d621

File content as of revision 0:fe729db7d621:

#include "mbed.h"
AnalogIn sensor(PB_0);
Ticker flipper1;
Ticker flipper2;
DigitalOut led1(PD_13);
DigitalOut led2(PD_8);
float valor_analogo; 
Serial device(PA_2,PA_3);
 
void flip1()   // flip 1 function
{
    valor_analogo=sensor.read();
    device.printf("El valor analogo es en el timmer_1: %f \r\n", valor_analogo);

}
 
void flip2()   // flip 2 function
{
    valor_analogo=sensor.read();
    device.printf("El valor analogo es en timmer_2: %f \r\n", valor_analogo);

}
int main()
{
    device.baud(9600);//Velocidad de Comunicacion
    led1 = 0;
    led2 = 0;
 
    flipper1.attach(&flip1, 0.2); // the address of the
// function to be attached
// and the interval (sec)
    flipper2.attach(&flip2, 1.0);
// spin in a main loop
// flipper will interrupt it to call flip
 
    while(1) {
        wait(0.2);
    }
}