Control de rebotes.

Dependencies:   mbed

Files at this revision

API Documentation at this revision

Comitter:
jangelgm
Date:
Thu Mar 09 21:49:01 2017 +0000
Commit message:
Control de rebotes.

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 44c7fcb872d1 main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Thu Mar 09 21:49:01 2017 +0000
@@ -0,0 +1,23 @@
+/* Program Example 9.12: Event driven LED switching with switch debounce
+*/
+#include "mbed.h"
+
+InterruptIn button(p18); // Interrupt on digital pushbutton input p18
+DigitalOut led1(LED1); // digital out to LED1
+Timer debounce; // define debounce timer
+
+void toggle(void); // function prototype
+
+int main()
+{
+    debounce.start();
+    button.rise(&toggle); // attach the address of the toggle
+} 
+
+// function to the rising edge
+void toggle()
+{
+    if (debounce.read_ms()>10) // only allow toggle if debounce timer
+        led1=!led1; // has passed 10 ms
+    debounce.reset(); // restart timer when the toggle is performed
+}
diff -r 000000000000 -r 44c7fcb872d1 mbed.bld
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Thu Mar 09 21:49:01 2017 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/6c34061e7c34
\ No newline at end of file