Line
Follower Programming
There are two programs provided for the Line Follower.
Both programs use the Color Sensor in the "Light Sensor" mode, where the
sensor shines an LED lamp of one color (red is used here) and measures
the amount of light that is reflected back into the sensor, as a number
from 0 to 100. Although under good conditions it is possible to
follow a line using the Color Sensor in Color Sensor mode, the Light
Sensor mode is better for this task.
-
The LineFollow
program is a simple "Two State" line following strategy without any
sensor calibration. It will repeatedly turn either left or
right in a "zig-zag" pattern, alternating back and forth on either
side of the right edge of the line. Start the robot near the
right edge of the line.
To use this program,
you will usually want to first determine a good brightness value to
use as the "cut-off" between the two states (light and dark).
To do this, you can use the
LightMeter program to measure the brightness over the center of
the line (darkest), then over the open floor (brightest), then
average them to find the cut-off. For example, if the Light
Meter reads 20 over the line and 40 over the floor, then 30 would be
a good cut-off value.
-
The SmoothFollow
program is a much more complex "Proportional Line Follower" which
continually adjusts the steering response of the robot depending on
how far off the line the robot appears to be. If the robot is
only slightly off of the edge of the line, then only a small amount
of steering is applied. When the robot is exactly over the
right edge of the line, the robot will drive straight ahead at the
full power specified. This allows the driving to be smoother
and faster than the LineFollow program.
In addition, the
SmoothFollow program does an automatic "calibration" sequence at
the beginning, where the robot scans the line and the surface to
determine darkest and brightest light values to expect, so there is
no need to manually determine a cut-off value. To get a proper
calibration, start the robot with the sensor directly over the
center of the line.
|