MSOE EE2905 / Mbed 2 deprecated Button

Dependencies:   mbed

Fork of Button by Sheila Ross

Files at this revision

API Documentation at this revision

Comitter:
rossatmsoe
Date:
Sat Aug 12 20:05:45 2017 +0000
Commit message:
Initial version of Button 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:05:45 2017 +0000
@@ -0,0 +1,26 @@
+/* Button
+
+Reads the USER_BUTTON and flashes LED if pressed.
+
+based on built-in mbed example Nucleo_read_button
+modified 12 Aug 2017 by Sheila Ross
+
+*/
+
+#include "mbed.h"
+ 
+// Declare USER_BUTTON to be a digital input
+DigitalIn mybutton(USER_BUTTON);
+
+// Declare LED1 to be a digital output
+DigitalOut myled(LED1);
+ 
+int main() {
+  while(1) {
+    if (mybutton == 0) { // Button is pressed
+      myled = !myled; // toggle LED on/off
+      wait(0.2);
+    }
+  }
+}
+ 
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Sat Aug 12 20:05:45 2017 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/fd96258d940d
\ No newline at end of file