Robotics
Making a simple Line Sensor
Dec 7th
What is a line sensor?
Line Sensor is one the most commonly used Detector in Robotics. It is used to detect the presence of a line. It has or applications. Theoretically, it detects the intensity of light reflecting off a surface. In most competitions, the robot either has to follow a line, or navigate a grid. So you are provided with white lines on a black surface. What this sensor does is it checks the amount of light reflected off a surface and outputs it as a voltage level, which may range from Vcc to a certain minimum value depending on the characteristics of the photodetector.
The principle is that different colors reflect different amount of light, white being the most reflecting, black being the least. So when using this on a black surface with white lines, when you get a high reading, the line is present(white is detected), when you get a low one, line is absent. These are generally used in groups of 208 to help decide which direction to turn
Here’s a diagram for a simple line sensor.
The data pin is attached to an ADC or the ADC pins, if your microprocessor has an inbuil one like AVRs, the others are obvious. Don’t supply more than 8 Volts to the circuit or it may get damaged. If you donot have an ADC on your board, just use a comparator and compare it to some constant value.
You wold want to first get a reference value for the given scenario, then use it so you can adjust to ambient lighting. You may also want to cover theĀ The photodetector with a tape so it is not sensitive to ambient lighting in the first place.
int wref;
function get_refernce(){
::wref=Read_ADC(Channel)
}
void main(){
if (Read_ADC(Channel)<wref-20)
{
//Line is absent. Do something. Move the robot, stop it whatever
}
}
That’s a sample code. Just a sample, not really usable, so don’t copy paste it.. It just explains how this thing works. I’ll write a better tutorial someday…
