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: PololuEncoder Pacer mbed GeneralDebouncer
line_sensors.cpp
00001 #include "line_sensors.h" 00002 00003 DigitalInOut lineSensorsDigital[LINE_SENSOR_COUNT] = { 00004 DigitalInOut(p18), // white wire, left-most sensor 00005 DigitalInOut(p19), // orange wire, middle sensor 00006 DigitalInOut(p20), // brown wire, right-most sensor 00007 }; 00008 00009 void readSensors(uint16_t * values) 00010 { 00011 for(uint8_t i = 0; i < LINE_SENSOR_COUNT; i++) 00012 { 00013 values[i] = 1000; 00014 lineSensorsDigital[i].mode(PullNone); 00015 lineSensorsDigital[i].output(); 00016 lineSensorsDigital[i].write(1); 00017 } 00018 00019 wait_us(10); 00020 00021 Timer timer; 00022 timer.start(); 00023 00024 for(uint8_t i = 0; i < LINE_SENSOR_COUNT; i++) 00025 { 00026 lineSensorsDigital[i].input(); 00027 } 00028 00029 while(timer.read_us() < 1000) 00030 { 00031 for(uint8_t i = 0; i < LINE_SENSOR_COUNT; i++) 00032 { 00033 if (values[i] == 1000 && lineSensorsDigital[i].read() == 0) 00034 { 00035 values[i] = timer.read_us(); 00036 } 00037 } 00038 } 00039 }
Generated on Sun Jul 17 2022 15:45:15 by
1.7.2