ESE519-Reading from mat

Dependencies:   mbed

Files at this revision

API Documentation at this revision

Comitter:
chirags
Date:
Sun Oct 23 21:12:10 2016 +0000
Commit message:
Basic sensor reading

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	Sun Oct 23 21:12:10 2016 +0000
@@ -0,0 +1,29 @@
+#include "mbed.h"
+
+DigitalOut select0_mux1(p24);
+DigitalOut select1_mux1(p23);
+DigitalOut select2_mux1(p22);
+DigitalOut select3_mux1(p21);
+AnalogIn analog_read_1(p20);
+
+int getBit(int num, int bitNo) {
+        return ((num&(1<<bitNo)) > 0)?1:0;
+}
+
+int main() {
+    while(1) {
+        
+        for (int i = 0; i< 16; i++) {
+            printf("Select Line: %d ", i);
+            
+            // This code will select the select lines on the mbed
+            select0_mux1 = getBit(i, 0);
+            select1_mux1 = getBit(i, 1);
+            select2_mux1 = getBit(i, 2);
+            select3_mux1 = getBit(i, 3);
+            wait(0.01);
+            printf("Analog Read Value: %f\n ", analog_read_1.read());
+            wait(3);   
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Sun Oct 23 21:12:10 2016 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/25aea2a3f4e3
\ No newline at end of file