Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed
Fork of Lab_6_WaG by
Diff: wag.cpp
- 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