The Bowmar Builders are an FLL team associated with Bowmar Elementary School. The purpose of this blog is to help other students interested in robotics to learn from what we have learned. As an FLL Robotics team we use the Lego EV3 robotics system and the Mindstorms graphical programming language.

Saturday, May 28, 2016

Follow That Line Algorithm

By Mateo B.


The FollowThatLine algorithm makes the robot follow the line for a certain number of rotations. It is a two-sensor line following algorithm.

Robot Setup

The two color sensors need to be 1/2 block off of the mat. They need to be 1 block apart from each other. This lets them track both sides of the black and white line on the mat. The robot has the two color sensors plugged into ports 2 and 3, with the one in port 2 on the left. The drive motors are plugged into ports B and C.

Outer Control Loop

The outer control loop repeats the logic until the exit condition is met. The exit condition is the number of rotations. The overall logic uses a state-based system where the wheels are just turned on rather than on for a specific time, degrees, or distance. The outer control loop determines when to be done. The wheels are not turned off at the end of the algorithm.

Exit Condition

The exit condition is go until greater than or equal to a number of wheel rotations. The exit condition is hooked up to an input parameter. This makes it so when you add the myblock you type how far the robot goes. To make the parameter you add a numerical parameter when you make the myblock.

First Switch Block

The algorithm is controlled by two switch statements. The first switch block tests if sensor 3 (the right sensor) is less than or equal to a reflectance value of 50 (darker than half black and white). The options are true, meaning we have moved to too dark, or false, meaning that it is either ok or too white.

First Switch Block - True

If sensor 3 measures too dark then the robot has steered to the left and we want it to start steering to the right. This is done by adjusting the power to each wheel.

First Switch Block - False

If it is false we need to figure out if we need to steer right.

Inner Switch Block

In the inner switch block for the false value of the outer switch block, the robot tests sensor 2 (on the left) for a reflectance intensity less than or equal to 50. This will test to see if the robot has steered too far right.

Inner Switch Block - True

If it is true steer left because the robot is to far to the right. You do this by adjusting the wheel power to B and C.

Inner Switch Block - False

If it is false then the robot is neither too far left nor too far right. The robot needs to steer forward by setting the wheel power to the same number.


The FollowThatLine algorithm uses two switch statement to determine if the robot needs to steer left, right, or go straight. The steering is done by adjusting power to the two drive wheels. The exit condition is a motor turning a desired number of revolutions. The key sensing mechanism is if the two color sensors are measuring a value of 50 or less, meaning too dark (over the black line.) The algorithm assumes that it starts somewhere close to being correctly over the line (the black line will be between the two sensors.)

No comments:

Post a Comment