Examples > Robot?

Line Following

Take a large piece of paper (or tape smaller pieces together to make a big one) and draw a shape on it using a thick black marker. This shape will be your racing track.

Put the robot on top of the line and turn it on. It will scan the floor to detect the line. When it finds the line, it will start following it the path.

Compete with other robots to see which one makes it faster!

Hardware Required

  • Arduino Robot
  • Large piece of white paper
  • Thick black marker
  • tape


  1. Prepare the track. Draw a thick line on soem white paper, making sure the ends of the line goes together. Use multiple pieces of paper if one is not big enough. The line should be around 3cm (1 inch) wide.
  2. Tape the paper to the ground so the robot will not cause the paper to slip. The surface should have light color.
  3. Upload the example, unplug USB and turn on power.
  4. Place the robot on the track, so it is facing down the line.
  5. After the starting screen, the robot will calibrate itself. It'll wag around a few times, detecting the line.
  6. The robot will start following the line. If everything goes OK, it'll be continuously going around the track. If the robot goes off the line, see lineFollowConfig() for details about how to calibrate it.

Try it out

Draw your own racing track

Let your robot run the race!


SORRY, There is an error at our code repository, please inform to web@arduino.cc

How it works

The Robot has five infrared sensors on the bottom of the motor board that detect where light reflects back. That information is be used to decide whether to continue straight or to change the wheel speeds to turn.


When the robot detects a black shape covering all the five sensors at once, it will stop. Use this feature to create tracks for the robot to stop and perform actions.

See Also: