Completed ready for demo- scan_mux_fun

Dependencies:   mbed

Fork of Microprocessors_Template by EECS397

Revision:
1:cff235122df8
Parent:
0:24202d4eadef
Child:
2:69ec832f181c
--- a/main.cpp	Tue Jan 30 18:13:24 2018 +0000
+++ b/main.cpp	Sat Feb 03 17:49:10 2018 +0000
@@ -1,23 +1,56 @@
 /*******************************************************************************
 *EECS397
 *
-*Assignment Name: Lab 
+*Assignment Name: Lab 3; Scan Mux
 *
 *Author(s): Ashley Roberson, Michael Codega
 *
-*Purpose:
+*Purpose: Scans all 16 channels, stores those analog values in an array, and
+*         then prints values in array to serial console with each channel
+*         labeled when a key from the serial console is pressed.
 *
-*Last Modified: , 2018
+*Last Modified: February 3, 2018
 *
 *******************************************************************************/
 #include "mbed.h"
 
+Serial pc(USBTX, USBRX);
+char input;
 
-int main(void) {
-    
-    
-    
-    
-    
-}    
-    
\ No newline at end of file
+float channelData[16];
+BusOut muxSel(PC_6, PB_15, PB_13, PB_12);
+
+AnalogIn muxOut(PB_1);
+
+int main(void)
+{
+
+    while(1) {
+        // wait for an input character to be rx'ed
+        while(!pc.readable()) {
+            ; // do nothing
+        }
+
+        input = pc.getc();
+
+        // business logic:
+        // scan 16 channels, store those values in array
+        // print array
+
+        for(int i = 0; i < 16; i++) {
+            // scan channels
+            muxSel = i;
+
+            wait(0.00001);
+
+            channelData[i] = muxOut.read();
+        }
+
+        for(int i = 0; i < 16; i++) {
+
+            //print out
+            pc.printf("The channel data for %d is: %d\n", i, channelData[i]);
+
+        }
+    }
+}