Use the button on Nucleo board in Interrupt mode

Dependencies:   mbed

Files at this revision

API Documentation at this revision

Comitter:
sjallouli
Date:
Mon Dec 28 23:04:25 2015 +0000
Commit message:
Use the button in interrupt mode on the Nucleo board

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 1b77c1ffae11 main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Mon Dec 28 23:04:25 2015 +0000
@@ -0,0 +1,29 @@
+#include "mbed.h"
+
+DigitalOut myled(LED1);
+InterruptIn mybutton(USER_BUTTON);
+
+float delay = 1.0; // 1 sec
+
+void pressed()
+{
+  if (delay == 1.0)
+  {
+    delay = 0.2; // 200 ms
+  }
+  else
+  {
+    delay = 1.0; // 1 sec
+  }
+}
+
+int main() 
+{
+  mybutton.fall(&pressed);
+    
+  while (1) 
+  {
+    myled = !myled;
+    wait(delay);
+  }
+}
diff -r 000000000000 -r 1b77c1ffae11 mbed.bld
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Mon Dec 28 23:04:25 2015 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/7cff1c4259d7
\ No newline at end of file