Allume/éteint la LED quand on appuie sur le bouton

Dependencies:   mbed

Files at this revision

API Documentation at this revision

Comitter:
valdub
Date:
Thu May 15 08:23:02 2014 +0000
Commit message:
Program published

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 c72f09731dd4 main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Thu May 15 08:23:02 2014 +0000
@@ -0,0 +1,26 @@
+#include "mbed.h"
+
+DigitalOut myled(LED1);
+InterruptIn button(USER_BUTTON);
+Timer debounce;
+
+int i=0;
+
+void toggle()
+{
+    if (debounce.read_ms() > 100) {
+        i = !i; }
+    debounce.reset();
+}
+
+int main() 
+{
+    myled = 0;
+    button.rise( &toggle );
+    debounce.start();
+    
+    while (1) 
+    {
+        myled = (i == true) ?1 :0;
+    }
+}
diff -r 000000000000 -r c72f09731dd4 mbed.bld
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Thu May 15 08:23:02 2014 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/6473597d706e
\ No newline at end of file