Simple Line Following with SPIKE Prime Pro Preview

Line following is a very common competition category. Here's how you can get started with it!

To access the full video please subscribe to FLLCasts.com

Subscribe

  • #2316
  • 31 Jul 2024

snimka

Line following may seem simple at first glance. You think you just have to program the robot to go forward when it's on the line and to turn towards the line when it's not on the line. The problem is that the second part is impossible to program as you can't know which side of the line the robot is. Should it turn left towards the line? Should it turn right?

That's why most line-following algorithms follow the edge of the line instead of the entire line. By following the left edge, for example, the robot always knows it can turn right towards the line.

snimka

The basic algorithm looks something like this:

  • If the robot is on the black line, turn towards the edge.
  • If the robot is outside of the line, turn towards the line.

So, if we choose to follow the right edge, the robot should turn right until it detects white and then turn left until it detects black. When placed in a forever loop, the robot should successfully follow the black line! This algorithm can be implemented with both wait until blocks and if/then blocks.

Courses and lessons with this Tutorial

This Tutorial is used in the following courses and lessons

Image for Level B2 - Introduction to Robotics Competitions   - Robotics with LEGO SPIKE Prime
  • 21
  • 1:03
  • 60