In this video tutorial we demonstrate the classic algorithm for following a line with robots. It is widely used in FIRST LEGO League competition and could be applied to LEGO Education SPIKE Prime and to other robots also. The algorithm follows a line by moving to the left and to the right and trying to stay at the edge of a black line.
- #1933
- 29 Jun 2022
- 2:54
- LEGO Education SPIKE Prime
- Line follow, Line follow, Scratch, LEGO Education SPIKE App Word Blocks 2, Programming, Sensors, Light and Color Sensor
Why is it important?
The only way to know where the robot is on a FIRST LEGO League field is to use sensors. There is practically no other way. Sensors is what make the robot consistent and reliable and with this program we demonstrate the line following.
How to use this tutorial?
Download the program. Experiment with it. Try to follow a line. Change the values for turning and it this way you will learn how to follow the line.
English
In this video tutorial we use LEGO Education SPIKE Prime and we are going to follow a line with a light sensor. This black line right here. We start from the base. We develop a simple program, two states. Let's now take a look how the program works. We follow the line. We follow the line with the light sensor and you can see that we are moving to the left and to the right. Left, right, left, right. And in this way we keep a straight line. And this is a simple program with two states. You either see white or you see black. And we've implemented this program for the left sensor, but you can also change it for the right sensor. The goal is move forward, follow the line, start from the base, move forward or follow the line. Simple two state program. Let's dig into the program and see how we implement this with Scratch Word Blocks. This here is the Scratch program for our robot. We have the Scratch program and let's look at it. When the program starts, we set move on to motors A and B, which is generally for most of the programs of this robot. And then the different thing is that we set movement speeds to 30%. We decided for this tutorial to have 30%. After that, what we do is that for 10 seconds we run this loop, repeat until and what the loop does is a check, a simple check. If sensor E detects color black, then move to the right. If it detects color white, then move to the left. And here it is how it works. We start with a robot. We move, we detect white, and as we detect white, we start moving to the left. We detect black, we move to the right. White, left, black, right and that's it. We repeat this until the timer shows 10 seconds. That's it. Quite simple as a program, very powerful. It's the general algorithm for following alliance with this and not only these robots. What you should do now is download this program and experiment with it, see how it behaves for your robot and see you in the next tutorial.
Курсове и занятия включващи този Урок
Този Урок е използван в следните курсове и занятия.

LEGO Education SPIKE Prime Programming for competition with Word Blocks
Two concepts are important for robotics competitions - consistently navigate and position the robot exactly where we need it to be on the field, and builing attachments that would accomplish a mission once we have reached it. This course is focused on the first part. The second part is the whole FLLCasts platform, but start at FIRST LEGO League with LEGO Education SPIKE Prime. "Challenge" competition for 9-16 years old
The goal of this course is the help you learn to program LEGO Education SPIKE Prime robots to behave consistently and reliably during competitions. As a language we use LEGO Education SPIKE App Word Blocks which is based on Scratch. We look at a lot of concepts that could be used for FIRST LEGO League and World Robot Olympiad competitions - eg how to follow a line fast, slow, in a smooth way, with 5 states. Also how to align to lines, how to do double alignment, how to keep a straight line with motion sensor.
- 40
- 188:21
- 19

Color Sensor - Follow a line with a 2 states algorithm
In this video tutorial we demonstrate the classic algorithm for following a line with robots. It is widely used in FIRST LEGO League competition and could be applied to LEGO Education SPIKE Prime and to other robots also. The algorithm follows a line by moving to the left and to the right and trying to stay at the edge of a black line.
- 2
- 0
- 1
- 3d_rotation 1