Internal Pullup Example

Dependencies:   mbed

Files at this revision

API Documentation at this revision

Comitter:
ogata_lab
Date:
Wed May 29 05:30:11 2013 +0000
Commit message:
Internal Pullup example

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	Wed May 29 05:30:11 2013 +0000
@@ -0,0 +1,19 @@
+#include "mbed.h"
+
+DigitalOut led1(LED1);
+
+// Pin name can also be used to initialize DigitalIn and DigitalOut.
+DigitalIn sw1(p20);
+
+int main() {
+    // Inner pull up on
+    sw1.mode(PullUp);
+        
+    while(1) {
+        if (sw1 == 0) { // If Pushed
+           led1 = 1;
+        } else { // Else (if not pushed)
+           led1 = 0;
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Wed May 29 05:30:11 2013 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/b3110cd2dd17
\ No newline at end of file