as a five to seven (or more)
sensor line following bar, using
only three analog inputs.
There is a down side to
using analog line detectors:
You have to calibrate them,
and they are influenced by the
level of ambient lighting.
The good news is that by
calibrating the sensors, you can
handle dark tape on a light
background or light tape on a
dark background fairly easily.
Please note that the better the
contrast between background
and line, the easier it will be
for your robot to detect the
I like simplicity, so I use a
very simple calibration scheme
for line following:
FIGURE 3. Line sensor mounted on Robbie.
greatly limits the speed at which the robot can follow the
line because it will have to hunt around more for the line
to follow if it happens to leave the line. Two sensors work
much better because the robot can keep going in the
direction it is moving in until it "sees" that it is moving off
the line by sensing the line on the left or right. Three
sensors work even better. The robot can tell when the line
is directly beneath the central sensor, and can also notice
which direction it is drifting off the line when the line
curves with even more sensors, the robot can tell how far
it is off the line, and make more precise course
corrections. However, it will use up more I/O pins and
require more sophisticated programming.
For Robbie, I decided to build a line following sensor
using three SirMorph IR sensor modules as shown in
SirMorph provides analog outputs from each sensor.
This allows sensing how much of the line is in the field of
view, thereby allowing more sophisticated software which
can notice that the robot is leaving the central sensor and
in which direction. This provides nearly the same capability
• Take one reading with all
three line sensors looking at
a white background.
TABLE 2. Test sample readings.
This allows RoboProp to save calibration values for
each sensor for both "over line" and over "background"
The greater the difference between the over line and
over background reading, the easier it will be for RoboProp
to follow lines. If the difference is great enough, RoboProp
will even be able to tell (roughly) where the line is relative
to the three sensors. Table 2 shows some test sample
For illustration purposes, let's assume I have the
background and line levels from Table 2 when calibrating
RoboProp. (I will supply some real values in a later table.)
You can see that for simple line following code, you
can make judgments about where the line is simply by
checking for (Sensor < 750) as that would clearly indicate
which sensor the line was closest to.
Of course, you can detect if there is no line near any
of the sensors by testing for all sensors having a value
close to the background level; if your robot crossed a
horizontal line during its travel, you would get a value
close to the line level on all sensors.
Once you have the basic line following code
working, you can experiment with controlling the rate
of turning for the robot based on the "distance to line"
value read from the sensor. That is, the closer a sensor
reads to the line value, the closer that sensor is to the
line. The converse is also true: The further a sensor is
to the line, the closer the sensor value will be to the
background level. This lets you know approximately
where the robot is in relation to the line. The line
sensors also allow robots to navigate a virtual maze.
44 SERVO 10.2011