Read a digital value using the button

Dependencies:   mbed

Files at this revision

API Documentation at this revision

Comitter:
jose_23991
Date:
Mon Sep 08 17:36:20 2014 +0000
Commit message:
Version 1.0

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 56ee1a2414d7 main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Mon Sep 08 17:36:20 2014 +0000
@@ -0,0 +1,16 @@
+#include "mbed.h"
+  
+int main()
+{
+    DigitalIn button(USER_BUTTON, PullUp); // Create the button object and setup internall pull-up resistor
+    DigitalOut led(LED1, 0);               // Create the LED object and setup OFF
+
+    while(1)
+    {
+        if(button == 0)                    // Button is pressed
+        {
+            wait_ms(500);                  // Wait 500ms to debounce
+            led = !led;                    // Toggle the LED state
+        }
+    }
+}
diff -r 000000000000 -r 56ee1a2414d7 mbed.bld
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Mon Sep 08 17:36:20 2014 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/9327015d4013
\ No newline at end of file