Lab 6 code.

Dependencies:   mbed

Fork of WaG by GroupA

Revision:
40:4e82369f337c
Parent:
35:7b562e336a26
Child:
43:3b7f326aa096
--- a/analog.cpp	Fri Mar 23 20:16:24 2018 +0000
+++ b/analog.cpp	Fri Mar 23 21:24:26 2018 +0000
@@ -55,6 +55,7 @@
 */
 void ana_scan_mux(float * an_array, int no_of_channels) {
     for (int i = 0; i < no_of_channels; i++) {
+        mux_select = i;
         an_array[i] = mux_out.read();
     }
 }
@@ -72,10 +73,14 @@
 */
 void test_phototransistors () {
     // check for button pressed and released to start PT scan test
-    ana_scan_mux(phototransistor_array, MUX_CHANS);
-    for (int i = 0; i < MUX_CHANS; i++) {
-        pc.printf("PT%d: %f\t", i, phototransistor_array[i] * 3.3f);   
+    while (uti_chk_ubutton() == 0);
+    pc.printf("test begin\n");
+    
+    while (uti_chk_ubutton() == 0) {
+        ana_scan_mux(phototransistor_array, MUX_CHANS);
+        for (int i = 0; i < MUX_CHANS; i++) {
+            pc.printf("%d: %.3f   ", i, phototransistor_array[i] * 3.3f);   
+        }
+        pc.printf("\e[1;1H\e[2J");
     }
-    fflush(stdout);
-    // check for button pressed and released to finish PT scan test
 }
\ No newline at end of file