Gapped & Crossed Line Following with LEGO Mindstorms. Part 1. Challenge

We start a course for following a line with crosses and gaps. This is a challenge that one of the users at was trying to accomplish and asked us for advice. We present the whole challenge to you step-by-step. But first, let's also see the whole line following run. With this course we also do and introduction of using State Machine as a programming pattern.

  • # 204
  • 06 Jan 2016
  • 2:45

The gaps are 0.1 meters in length. The robot doesn't know where the gaps are, where the turns are. It should come from the start to the end. We show the complete line following run so that you have an idea of how the whole program behaves and what the result at the end will be. 

The only why to properly learn how to follow lines is to actually do the programming at each step. Try to program the robot, and then share the results with us of how successful it was. 

While programming we implement a pattern. This patter is called "State Machine". A state machine has a number of states and transitions between these states. We sometimes call these transitions "behaviours". 

Full course available at

Gaped and Crossed Line Following with LEGO Mindstorms


For this video we got a request for more advanced line following algorithm for a robot that can follow a the line as shown on this field. This is a field from one of the users at and we desided to build an algorithm that can follow this line. As you can see it's pretty complex, it has turns, it has gaps and it also has cross sections. It's a very interesting line and we decided to build this in the next few video, in this course we'll describe how do you program the robot to follow such a line. Now let's see an example and what is the final result from our work.

As you saw the robot was successful. Now let's look at the program and learn how do you build such a line following algorithm.