use a digital input in pull up mode to read a signal from a microswitch and toggle a LED

Dependencies:   mbed

Revision:
0:9330a73f2ea2
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Sun May 14 19:19:34 2017 +0000
@@ -0,0 +1,18 @@
+#include "mbed.h"
+
+DigitalIn micro(D0, PullUp);
+DigitalOut myled(LED1);
+
+int main() {
+    while(1) 
+    {
+        if (micro)
+        {
+            myled = 0; // LED is ON
+        }
+        else
+        {
+            myled = 1; // LED is OFF
+        }
+    }
+}