While "multistate line following" can describe a variety of algorithms, this tutorial will cover its implementation using the ducky line-following method.

To access the full video please subscribe to FLLCasts.com
- #2293
- 02 Aug 2024
As the name implies, we will be adding more states to the ducky line-following method. In its simplest form, the ducky line-following method consists of two states:
- If the robot is on the line, turn in one direction.
- If the robot is not on the line, turn in the opposite direction.
By adding a third state, we can increase the speed at which the robot completes the track. The third state would look like this:
- If the robot is on the line, turn in one direction.
- If the robot is partly on the line, move forward.
- If the robot is not on the line, turn in the opposite direction.
As you might guess, adding states requires us to use the reflected light property of the light sensor rather than color detection. Instead of detecting the color of the line, the robot must measure the amount of light reflected back to the sensor to determine how well it is positioned on the line. In the two-state program, the state conditions look like this:
- If the light sensor detects black, the robot is on the line, so turn in the set direction.
- If the light sensor does not detect black, the robot is off the line, so it should turn in the opposite direction.
In the three-state program, the state conditions look like this:
- If the light sensor detects very little reflected light, the robot is on the line, so turn in the set direction.
- If the light sensor detects a moderate amount of reflected light, the robot is partly on the line, so it should move forward.
- If the light sensor detects a lot of reflected light, the robot is off the line, so it should turn in the opposite direction.
By adding more states and fine-tuning them to the robot's construction and the field, the robot will complete the track even faster.
Courses and lessons with this Tutorial
This Tutorial is used in the following courses and lessons

Line Following
This is the Line Following course, where you’ll explore essential techniques to help your LEGO robot follow a line with accuracy and stability! We will begin by covering the fundamental concepts of line following, starting with basic wobble line following, which teaches how robots detect and respond to lines. Then, we'll progress to more advanced methods like proportional line following, allowing smoother tracking by adjusting speed based on error values. Finally, you'll dive into the widely-used PID line following technique, where you'll learn how to tune parameters for optimal robot performance. Whether you're a beginner or looking to enhance your robotics skills, this course will guide you through building, coding, and refining your robot's line-following capabilities.
- 15
- 0:00
- 42

Wobble Line Following
This is the most basic line-following method, commonly known as the "ducky" line-following method.
- 3
- 0
- 8
- 3d_rotation 1