Richard Sanchez Pozo / Mbed 2 deprecated Lectura_AnalogIn_interrupcion

Dependencies:   mbed

Revision:
0:7811129277e5
diff -r 000000000000 -r 7811129277e5 main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Sat Feb 08 03:00:50 2020 +0000
@@ -0,0 +1,40 @@
+#include "mbed.h"
+Serial pc(PA_2,PA_3,115200);
+Ticker flipper1;
+Ticker flipper2;
+
+AnalogIn ain1(PC_1);
+DigitalOut led1(PD_12);
+DigitalOut led2(PD_14);
+float sensor1=0.0;
+float sensor2=0.0;
+
+void flip1()   // flip 1 function
+{
+    led1 = !led1;
+    sensor1 = ain1;
+    pc.printf("Valor1: %0.1f%%\n", sensor1*100);
+}
+
+void flip2()   // flip 2 function
+{
+    led2 = !led2;
+    pc.printf("Valor2: %0.1f%%\n", sensor2);
+}
+
+int main()
+{
+    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);
+    }
+}