Program to show a pin being dynamically configured as an analog and a digital

Dependencies:   mbed

Files at this revision

API Documentation at this revision

Comitter:
chris
Date:
Tue Oct 04 08:57:37 2011 +0000
Commit message:
First revision

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 7071e3e01101 main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Tue Oct 04 08:57:37 2011 +0000
@@ -0,0 +1,22 @@
+#include "mbed.h"
+
+int read_digital(void) {
+    DigitalIn mydigital(p20);
+    return(mydigital.read());
+}
+
+float read_analog(void) {
+    AnalogIn myanalog(p20);
+    return(myanalog.read());
+}
+
+int main() {
+    while(1) {
+    
+       printf("Digital reading : %d\n",read_digital());
+       wait(1.0);
+       printf("Analog reading : %.2f\n",read_analog());
+       wait(1.0);
+
+    }
+}
diff -r 000000000000 -r 7071e3e01101 mbed.bld
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Tue Oct 04 08:57:37 2011 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/63bcd7ba4912