Last part of the series. The final touch of the program makes sure that it works and is following the line with the LEGO Mindstorms EV3 Color Sensor in a smooth and fast way.

**#177**- 01 Nov 2015
- 5:47

- LEGO MINDSTORMS, LEGO MINDSTORMS EV3
- FIRST LEGO League, EV3-G, Advanced, EV3, Light and Color Sensor, FLL, Programming

### Important:

In the video the second math block is not correctly connected. Download the program from the Materials section to see the correct version.

The problem is that the output port from the sensor is connected to input "b" and should be connected to input "a".

### Previous episodes:

### Proportional Smooth Line Following

Use this program and you won't have problems in following lines with EV3 Mindstorms Color Sensor:

### English

This is the result that we currently have for the proportional following of a line. This is the result we want to have, very smooth program.

Finds the line very fast, follows it but this is the program that we currently have.

There is a difference in the program, especially the beginning and in this video we'll remove this jiggling in the beginning.

The secret here would be to somehow modify the values for the right and left motor so that they are larger and smaller but with a certain percentage. This would make the robot find the line much faster without so much movement and if we add one more value, right here, we multiply the result of subtracting 40 from the value of the sensor. We multiply this by 0,4 and this is 40% of the difference. We move with 40% of the difference and we add the same thing to the other Math block - 0,4. Download and run.

The robot finds the line and starts following it.

Let's return to the program for a minute. What you see here and the reason behind this 0,4 and multiplying by 0,4 is actually that we have the speed of the motor calculated from 2 things. The first is the constant speed that we would like the motor to have and then how fast we want the motor to rotate towards the line so how fast we want the robot to move to the line and we can experiment with these 2 values. We can experiment with the value 15 here and the value of 0,4. It is always a good practice when you have such constants to extract them in a new constant block, numeric and it will be 0,4.

We want to take this constant and pass it to the block as the variable c.

Then we want to multiply it not by 0,4 but by c.

This won't change the behavior of our program. Let's download and run it.

As you can see we've changed our program, the blocks but it behaves in the same way, which is great. There's one more thing we can improve in our program.

We have extracted the value c and it's equal to 0,4 as a constant and

with this constant we calculate how fast we want to turn to the line and we also have the constant speed which is 15 and I add another constant with the value of 15 and I take it to the Math block and it would be the d parameter.

We also change it in the other block.

This also won't change the behavior of our program but we can now customize these 2 parameters. What's the constant speed and how fast do we want to turn to the line. By modifying these to parameters you can customize this program for your particular robot. It depends of course what's the distance between the different sensors, what's the light in the room and how white is the line and what's the construction. By modifying these 2 constants we can modify our whole program. Let's just zoom out. This is the program for a proportional following that's very, very smooth.

Find the instructions for building this robot and doing this proportional line following algorithm below the video you can download and use the whole program in your programs.

## Courses and lessons with this Tutorial

This Tutorial is used in the following courses and lessons

### FIRST LEGO League Competition. Constructing and Programming a Robot Base

This course if used by teams, mentors and students to structure the preparation for the Robotics Game of the FIRST LEGO League Robotics Competitions. One thing that is common each year at FLL is that experience matters a lot. Our goal with this course is to quickly bring new teams up to speed with experienced teams and to share some new tricks, patterns, constructions with the more experienced teams.

- 42
- 249:53
- 10

### Faster and more precise line following

The next very good way on following line is to use a Proportional, Integral, Differential algorithm. Now, this could get quite complex so we have sciped the Integral and Differential Part from the next few videos and we have implemented only the Proportional. A very good line following that should do the job for nearly any competition.

- 4
- 1
- 0
*3d_rotation*0