Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed
Fork of Button by
Diff: main.cpp
- Revision:
- 0:cf7f8e884a7e
--- /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
