Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed
Revision 0:b765c25dc19d, committed 2016-10-31
- Comitter:
- MDevolution
- Date:
- Mon Oct 31 11:17:57 2016 +0000
- Commit message:
- Esercitazione5_10
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 b765c25dc19d main.cpp
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp Mon Oct 31 11:17:57 2016 +0000
@@ -0,0 +1,20 @@
+/* Program Example 10: Event driven LED switching with switch debounce
+*/
+#include "mbed.h"
+InterruptIn button(PC_13); // 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
+}
\ No newline at end of file
diff -r 000000000000 -r b765c25dc19d mbed.bld --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Mon Oct 31 11:17:57 2016 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/mbed/builds/9bcdf88f62b0 \ No newline at end of file