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

Dependencies:   mbed

Files at this revision

API Documentation at this revision

Comitter:
tgartlan
Date:
Wed Mar 14 08:54:18 2018 +0000
Commit message:
A simple program to pirnt the ADC values in float and hex. The hex representation allows us to see the 12 bit returned from the ADC

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 1ef96441fa7d main.cpp
--- /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
+    }
+}
diff -r 000000000000 -r 1ef96441fa7d mbed.bld
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Wed Mar 14 08:54:18 2018 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/6473597d706e
\ No newline at end of file