Aanalog I/O Example including pc.printf

Dependencies:   mbed

Files at this revision

API Documentation at this revision

Comitter:
Richard37
Date:
Wed Dec 10 15:13:01 2014 +0000
Commit message:
Version including pc.printf

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 22b0d71732be main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Wed Dec 10 15:13:01 2014 +0000
@@ -0,0 +1,36 @@
+#include "mbed.h"
+
+DigitalOut myled(D2);
+AnalogOut my_output(PA_4);
+AnalogIn analog_value(A0);
+Serial pc(D8, D2);
+
+int x;
+int x1;
+int x2;
+int x3;
+int x4;
+int y;
+uint16_t aout;
+
+
+int main() {
+    while(1) {
+        myled=1;
+        int meas = analog_value.read_u16(); // Converts and read the analog input value
+        x=meas;
+        y=(x+x1+x2+x3+x4)/5;
+        //y=x;
+        aout=y;
+        x4=x3;
+        x3=x2;
+        x2=x1;
+        x1=x;
+        my_output.write_u16(aout);
+        wait_us(50);
+        wait(.1);
+        myled=0;
+        pc.printf("%d\n\r", x);
+      
+    }
+}
\ No newline at end of file
diff -r 000000000000 -r 22b0d71732be mbed.bld
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Wed Dec 10 15:13:01 2014 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/ed8466a608b4
\ No newline at end of file