MSOE EE2905 / Mbed 2 deprecated ButtonInterrupt

Dependencies:   mbed

Fork of ButtonInterrupt by Sheila Ross

Files at this revision

API Documentation at this revision

Comitter:
rossatmsoe
Date:
Sat Aug 12 20:13:26 2017 +0000
Commit message:
Initial version of ButtonInterrupt program for MSOE EE2905

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
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Sat Aug 12 20:13:26 2017 +0000
@@ -0,0 +1,35 @@
+#include "mbed.h"
+
+// Declare that the USER_BUTTON will trigger an external interrupt mybutton
+InterruptIn mybutton(USER_BUTTON);
+
+DigitalOut myled(LED1);
+
+// Function prototypes
+void pressed();
+void released();
+  
+int main()
+{
+    // Define the behavior of the interrupt on rising and falling edges
+    mybutton.fall(&pressed);
+    mybutton.rise(&released);
+    
+    // do nothing; the interrupt servicing functions do all the work
+    while(1) {
+        wait(1);
+    }    
+    
+}
+
+void pressed() {  // short flash when pressed
+    myled = 1;
+    wait(0.2);
+    myled = 0;
+}
+
+void released() {  // long flash when released
+    myled = 1;
+    wait(1);
+    myled = 0;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Sat Aug 12 20:13:26 2017 +0000
@@ -0,0 +1,1 @@
+https://mbed.org/users/mbed_official/code/mbed/builds/a97add6d7e64
\ No newline at end of file