Stop the robot after the third line: Difference between revisions
Line 17: | Line 17: | ||
=== Example Videos === | === Example Videos === | ||
The video is about the second method, only. | |||
<youtube>hHpo12qUhgc</youtube> | <youtube>hHpo12qUhgc</youtube> |
Revision as of 21:14, 14 September 2020
Introduction
How to stop the robot after passing the third (or nth) line? This problem is very often encountered in FIRST Lego League (FLL) or in Rescue competitions. The problem is that the sensor reads continous data, and simple solution wont work.

This page gives to different solutions: (i) using timer or rotation angle to pass the lines and (ii) using flip-flop algorithm to count the black lines. The flip flop is a robust method which works with a variable width lines.
Robot
Almost any robot will do. We use Asimov 2/ Verne robot.
Sensors
One color sensor is needed.
Example Videos
The video is about the second method, only.
Theory
The two different methods are described below. The color sensor reads the reflected light intensity continuously, and the reading frequency is big. Thus, during passing the black line, the sensor reads perhaps hundreds of close to zero values. See, the image.

The calibrated color sensor reads about 100 at white, and while passing the black line it reads about 0.
Using the timer/ rotation angle
By using the timer we can drive past the black line, and again look for the next black line. After finding the third one, we stop. This can be done in a loop, also. Usually, if you need to repeat the code, use a loop.
Using flip flop circuit
The idea of the flip flop is that first we flip the state to black, and then after finding white we flop the state back to white. The sensor continuously measures the reflectance, and
Example Code
The example codes with two different algorithms are shown.
Using the timer
The timer based code is rather reliable and works perfectly even on difficult environments. The timer can be changed to rotation angle.

Using the flip flop algorithm
The flip flop algorithm is simple and reliable, if the ground floor is easy enough.

Exercises
- How fast can you make the robot to pass exactly three lines? Measure the time, and the extra passage (slippage), which the root makes after passing the last line.
- Make the robot work with two sensors, and assign other sensor to follow a line, and the other to stop after to stop the robot after 3rd line. See the image.
This course is supported by Meet and Code. The course is made in collaboration with Robotiikka- ja tiedekasvatus ry.
