Program to view the binary code returned from the 12 bit ADC

Dependencies:   mbed

Revision:
0:1ef96441fa7d
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Wed Mar 14 08:54:18 2018 +0000
@@ -0,0 +1,24 @@
+#include "mbed.h"
+Serial pc(USBTX, USBRX);
+AnalogOut Aout(p18);
+AnalogIn Ain(p20);
+
+DigitalOut myled(LED1);
+
+int main() {
+        unsigned short value = 0;
+        //download test
+        myled = 1;
+        wait(0.2);
+        myled = 0;
+        wait(0.2);
+        pc.printf("Ain value:-  ");
+    while(1) {
+        value = Ain.read_u16();
+        value = value >>4;
+        pc.printf("%d, ", value);  //send the float value to the PC  (Note this will introduce a delay, so be careful when you use serial comms
+        wait(5);                    //delay of serial comms in this case is irrelevant
+        
+        pc.printf("%x, ", value);   //to print in hex format...might be useful
+    }
+}