В момента ресурсът е наличен само на английски

# Simple (2 state) line follow with Color Sensor from LEGO Education SPIKE Prime ProPreview

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

## 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.

## Курсове и занятия включващи този Урок

Този Урок е използван в следните курсове и занятия.

• 40
• 188:21
• 19
• 2
• 0
• 1
• 3d_rotation 1