David's line following code from the LVBots competition, 2015.
Dependencies: GeneralDebouncer Pacer PololuEncoder mbed
Fork of DeadReckoning by
Diff: line_sensors.cpp
- Revision:
- 29:cfcf08d8ac79
- Parent:
- 28:4374035df5e0
- Child:
- 31:739b91331f31
--- a/line_sensors.cpp Sat Mar 01 03:13:57 2014 +0000 +++ b/line_sensors.cpp Tue Mar 04 00:46:18 2014 +0000 @@ -4,4 +4,25 @@ AnalogIn(p20), // brown wire, left-most sensor AnalogIn(p19), // orange wire, middle sensor AnalogIn(p17), // blue wire, right-most sensor -}; \ No newline at end of file +}; + +/** +uint16_t analogReadWithFilter(AnalogIn * input) +{ + uint16_t readings[3]; + for(uint8_t i = 0; i < 3; i++) + { + readings[i] = input->read_u16(); + } + + if (readings[0] <= readings[1] && readings[0] >= readings[2]) + { + return readings[0]; + } + if (readings[1] <= readings[0] && readings[1] >= readings[2]) + { + return readings[1]; + } + return readings[2]; +} +**/ \ No newline at end of file