Javier Nuñez
/
mbed_Interrupciones
Manejo de interrupciones para lectura de senal analoga.
Diff: main.cpp
- Revision:
- 0:fe729db7d621
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Sat Feb 08 02:59:13 2020 +0000 @@ -0,0 +1,39 @@ +#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); + } +} \ No newline at end of file