Line follower algorithm

From cod3v
Revision as of 10:44, 25 October 2020 by Mol (talk | contribs)


Introduction

The easiest line follower algorithm is Zig Zag algorithm, which goes like zig zag and never straight. However, it is funny to observe the movements of the robot, and test the meaning of the different parameters.

Aim

If block and loop block (programming). Color.

Robot

Almost any robot will do, but this example is done using Asimov 2/ Verne.

Sensors

The color sensor is used to read the color.

Example Video

Theory

Zig zag algorithm turns the robot to right if the sensor sees white, and to left if the sensor is on the black. Or vice versa. The algorithm is easy to program using only one if block and loop block. The speed and turning value need to be considered and adjusted.

The Zig Zag algorithm.

Example Code

Zig Zag never drives straight. Either it turns to left or right. However, it can be made very fast, and reliable---of course depending on the line. The turning part is coded into if else block which is in the loop.

Exercises

  • Use the other side of the line to follow the line
  • Make the robot to change the side of the line during the line following: Thus, after following the line e.g. 2 wheel rotations, use the other side of the line
  • Make a robot with two color sensors, and use the information from the other sensor to stop the robot when the other sensor recognizes black line.
  • Make a robot with two color sensors, and make the robot to follow a line that is in between the two sensors.
  • Make a robot with two color sensors, and make the robot to follow first the line with left sensor, then after two wheel rotations use the other sensor to follow the line to the end.


Back to Mahtavaa Matematiikkaa 2020



Mahtavaa matematiikkaa.png