David's line following code from the LVBots competition, 2015.
Dependencies: GeneralDebouncer Pacer PololuEncoder mbed
Fork of DeadReckoning by
Diff: line_sensors.cpp
- Revision:
- 40:e79cefc241f8
- Parent:
- 32:83a13b06093c
--- a/line_sensors.cpp Tue Apr 14 01:06:41 2015 +0000 +++ b/line_sensors.cpp Tue Apr 14 01:45:01 2015 +0000 @@ -1,14 +1,5 @@ #include "line_sensors.h" - -/** -AnalogIn lineSensorsAnalog[LINE_SENSOR_COUNT] = { - AnalogIn(p20), // brown wire, left-most sensor - AnalogIn(p19), // orange wire, middle sensor - AnalogIn(p17), // blue wire, right-most sensor -}; // TODO: remove -**/ - DigitalInOut lineSensorsDigital[LINE_SENSOR_COUNT] = { DigitalInOut(p18), // white wire, left-most sensor DigitalInOut(p19), // orange wire, middle sensor @@ -27,14 +18,14 @@ wait_us(10); - Timer timer; - timer.start(); - for(uint8_t i = 0; i < LINE_SENSOR_COUNT; i++) { lineSensorsDigital[i].input(); } + Timer timer; + timer.start(); + while(timer.read_us() < 1000) { for(uint8_t i = 0; i < LINE_SENSOR_COUNT; i++)