Following a black line

Two different ways to program a robot to follow a black line were explored during the sessions of the Robotics club of our school in the 2016-2017 season.

The first design is with only one light sensor. Yoy can download the LDD file from here : Design with one light sensor.

The robot moves on the edge of the black line executing the following algorithm:

  1. If the light sensor “sees” bright white then it means that the robot is to the right of the black line so it has to turn to the left and forward.
  2. If the light sensor “sees” black then it means that the robot is on the black line so it has to turn to the right and forward.

You can download this simple program from here: (LineFollow1).

You can also see a simulation of this behaviour in scratch:

Another way to implement the line follower is with two light sensors, or in our case with one light sensor and a color sensor used as light sensor. We place the two sensors on the robot in a way that the width of the black line can fit between them (Design with two light sensors).

Using this design the algorithm is as follows:

  1. If both sensors “see” white, that means that the black line is between them so the robot goes forward.
  2. If the right sensor “sees” black and the left “sees” white then the robot turns to the right.
  3. If the left sensor “sees” black and the right “sees” white then the robot turns to left.

You can download the program from here LineFollow2Sensors and you can see a scratch simulation below.