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

Dependencies:   mbed

Fork of Allumage_LED by Valentin Dubois

Revision:
0:c72f09731dd4
--- /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;
+    }
+}