One other fundamental aspect of line following (or edge following), which is typically not stated, is that the line follower program is always customized for the robot's starting position relative to the line. If you start out on the left side of the line, you need to rotate to the right in the line finding phase as Nari describes below. If you are on the right, you rotate left. This might seem obvious to you, but you might have to explain this to the team as they develop their line following programs. Once you find the line, then there are two ways to program the line follower depending on the relative color/darkness of the line and whether you are following the left or right edge.
I have observed teams use PID controllers in robot design judging (mostly at the World Festival) and in some cases it is overkill. When I am judging robot design, as most judges will do, for equally performing robots, the more simple design is considered to be the better one. Also, if your team is doing advanced programming, it is essential that the team understand what is programmed into the robot. I have listened to many teams explain complex programs to me and have been very impressed. For the few times the team was unable to fully explain their programming, although we give your teams the benefit of the doubt, it made the judges start wondering who was really doing the programming.
One of the most unique, and incredibly fast, line followers I have seen was during the Smart Move season. For those that remember, there was a black line oval which left the base and rotated counter clockwise (see the attached image). One of the World Festival teams wrote a program which, once it found the line, it put 100% power to the right (outside) motor and used line following techniques to adjust the power to the inside motor. It was incredibly fast. Also, and I cannot remember if the team did this, if you followed the right edge of the line, your line follower would be thrown off by the black lines branching to the right, but if you followed the inside (left) edge, you could line follow all the way to the end without any other lines interfering with the line following logic. These are a few examples, where if you have the team think about the problem and figure out what you want the robot to do, you will likely come up with an innovative solution which is better than just applying someone else's canned program the team found on the internet.

On Tue, Nov 20, 2012 at 1:50 PM, Anant Narayanan <[log in to unmask]> wrote:



The essence of line following is a left-right swinging motion with a sufficient forward bias.  Although called Line-following, most line followers are actually edge-followers, typically following either the left-edge or the right-edge of a thick black line.


The best way to teach line following is to first rotate in place (classically a 10-notch turn to left or right using a move block) until the color/light sensor finds the line.  This is a tricky step in which you have to play with the mechanical design to find the right amount of ground clearance for the sensor to work properly.  Sunlight often throws it off, as do many illumination systems.  This is why Scott Evans, the FLL game designer urges everyone to use a light shield to protect the sensor from ambient light.  This first phase is called Line Finding, and there are nuances to using light and color sensors which you will discover from practice.


After you have mastered using a light/color sensor for Line Finding, the next step is to start moving forward while still swinging left and right in alternating steps.  In plain english, this reduces down to:

1.      Swing left, while moving forward until you find (say) the right edge of a black line.  Classically, this is a 9-notch left turn using move blocks, but is popularly implemented as differential motor powers using motor blocks.

2.      Swing right, while moving forward until the sensor no longer sees black.

Steps 1 and 2 can be repeated ad infinitum to get a basic line follower.  If the robot gets stuck because the sensor get a spot that is neither black not while, I often teach the kids to program in a bias step (swing left as in step 1, swing off a fixed amount, repeat).


This is a simple line follower that can be tested on various shapes (sharp turns, smooth turns, hairpins, etc.).


Next up, from a simple line follower is a proportional line follower, in which the left-right swinging motion is matched to the curvature (technically to the "error" from the target zone).


In control systems design, we have three classes of controllers - proportional controllers, integral controllers and derivative controllers.  In proportional controllers, the corrective action is proportional to the error (small deviation leads to small correction; large deviation leads to large correction).  In derivative controllers, the corrective action is proportional to the slope of the error curve (is the problem getting worse, or better!).  In integral controllers, the corrective action is proportional to the area under the error curve (this equates to remembering that there was an error sometime in the recent past, and one is minimizing the area under the error curve).  The classical universal controller is called a PID controller -- it includes elements of a proportional controller, an integral controller and a derivative controller.


I saw a NXT-based PID controller at the State Championship a couple of years ago (a top-tier Div. II team).  It has been my dream to teach my teams how to build one, just for kicks (it is overkill for FLL).  Any year now! (if I ever get that far down my to-do list for the following year!). You rarely need to get beyond a proportional controller for any FLL competition.


You can find examples of a simple controller and a proportional controller at .  There are downloadable programs there as well, that are well documented.  As John said, there are numerous other resources as well.

This same approach also works for a wall-follower.


I hope this helps, and doesn't intimidate anybody who is not technically trained.


Best of luck,

Nari Narayanan

Anant S Narayanan
McLean Robotics Institute

McLean VA 22102
202-421-3826 (cell)
[log in to unmask]

On Tue, Nov 20, 2012 at 10:42 AM, John Barrett <[log in to unmask]> wrote:

I recommend taking a look at the site that veteran coach Wally Walter put together:



John J. Barrett
Industrial Medium Software, Inc.
1616 Anderson Road
McLean, VA 22102

(c) 703-231-5094
(p) 703-286-0818
(f) 703-286-0888

On Nov 20, 2012, at 10:07 AM, Emler, Paul wrote:

Dear Fellow FLL Coaches,
Now that the Bruin Brick Builder's season is over we are looking to the future. Our team did a good job this year in programming but we always want to learn more. We saw several robots that had a smooth line follow (not the back and forth motion of our line follow) Does anyone have resources available to teach us how to do that? Are there any book or web site suggestions? Thanks for helping a team to improve their approach.

Bruin Brick Builders
Team #1018
******** Confidentiality Statement: This electronic message and attachments are intended only for the use of the addressee and may contain confidential or privileged information. Receipt of this transmission by any person other than the intended recipient does not constitute permission to examine, copy, or distribute the accompanying material. If you received this electronic message in error, please notify the sender of the message. ********

-- To UNSUBSCRIBE or CHANGE your settings, please visit and select "Join or leave the list".

-- VADCFLL administrative announcements are sent via VADCFLL-ANNOUNCEMENTS-L. Visit to subscribe.

To UNSUBSCRIBE or CHANGE your settings, please visit and select "Join or leave the list".
VADCFLL administrative announcements are sent via VADCFLL-ANNOUNCEMENTS-L. Visit to subscribe.

To UNSUBSCRIBE or CHANGE your settings, please visit and select "Join or leave the list".
VADCFLL administrative announcements are sent via VADCFLL-ANNOUNCEMENTS-L. Visit to subscribe.

To UNSUBSCRIBE or CHANGE your settings, please visit and select "Join or leave the list".
VADCFLL administrative announcements are sent via VADCFLL-ANNOUNCEMENTS-L. Visit to subscribe.