GroupA / Mbed 2 deprecated WaG_final

Dependencies:   mbed

Fork of Lab_6_WaG by GroupA

Revision:
68:9245d6ce176e
Parent:
67:6dffd5c82eb6
Child:
69:1b7271bd4a75
--- a/wag.cpp	Thu Apr 19 15:42:22 2018 +0000
+++ b/wag.cpp	Thu Apr 19 15:49:06 2018 +0000
@@ -31,6 +31,7 @@
     int hit, miss = 0;
     int a_num;
     int led_command;
+    int msec;
 
     int whacker_no = 0;
     
@@ -57,13 +58,13 @@
         }
         
         clock_t start = clock();
-        clock_t finish = clock();
         pc.printf("Waiting for whacker...\n");
         
         do {
-            finish = clock(); // update timer
             ana_scan_mux(sensor_values, TGT_SENSOR_QUAN * 2); // scan all sensors
-        } while (finish - start < VOLLEY_DELAY or sensor_values[whacker_no + a_num] < PTTHRESH); // check if timer expired or if sensor hit
+            clock_t difference = clock() - start;
+            msec = difference * 1000 / CLOCKS_PER_SEC;
+        } while (msec < VOLLEY_DELAY or sensor_values[whacker_no + a_num] < PTTHRESH); // check if timer expired or if sensor hit
         
         if (sensor_values[whacker_no + a_num] > PTTHRESH) {
             hit++; // increment hit count