Sensores

Dependencies:   mbed

Files at this revision

API Documentation at this revision

Comitter:
franni
Date:
Wed Nov 29 21:14:19 2017 +0000
Commit message:
Sensores

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed.bld Show annotated file Show diff for this revision Revisions of this file
diff -r 000000000000 -r 03d37798399d main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Wed Nov 29 21:14:19 2017 +0000
@@ -0,0 +1,44 @@
+#include "mbed.h"
+
+DigitalOut led_alarm(LED1);
+Timer Timer2;
+InterruptIn  s0(PTD2);
+InterruptIn  s1(PTD4);
+
+bool flag_alarm,time_max;
+
+void ISR_S0()
+{
+    time_max=0;
+    Timer2.start();
+    flag_alarm=0;
+}
+
+void ISR_S1()
+{
+    time_max=1;
+    Timer2.stop();
+    flag_alarm=1;
+}
+
+int main()
+{
+    s0.mode(PullUp);
+    s0.rise(&ISR_S0);
+    s1.mode(PullUp);
+    s1.rise(&ISR_S1);
+    flag_alarm=1;
+    time_max=0;
+    while(1) {
+        if(flag_alarm==0) {
+            if(Timer2.read_ms()>=3000) {
+                if(time_max==0) {
+                    led_alarm=1;
+                    Timer2.stop();
+                    flag_alarm=1;
+                    time_max=0;
+                }
+            }
+        }
+    }
+}
diff -r 000000000000 -r 03d37798399d mbed.bld
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Wed Nov 29 21:14:19 2017 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/e7ca05fa8600
\ No newline at end of file