How to make your robot follow a line in mindstorms nxt

Written by matthew dehaven
  • Share
  • Tweet
  • Share
  • Pin
  • Email
How to make your robot follow a line in mindstorms nxt
A line-following robot can be a good way to get into programming with Lego Mindstorms. (Retro Robot & Son image by Infs from

The Lego Mindstorms NXT kit allows you to build and program a wide variety of robots, even if you have no prior programming experience. One good project for beginners would be to take a two-wheeled robot and set it up to follow a line drawn on paper.

Skill level:

Things you need

  • Mindstorms NXT kit
  • PC running Mindstorms programming software
  • Large sheet of white paper
  • Black marker

Show MoreHide


  1. 1

    Mount the light sensor (or colour sensor if you have the version 2.0 kit) to your robot so that it is pointing at the ground. Place the sensor just in front of and between the wheels, as close to the ground as possible. Plug the sensor into the NXT brick.

  2. 2

    Draw a line on your paper for your robot to follow. The line should be about 1/2 inch wide and have no sharp turns. The radius of any turn should be greater than half the width of your robot.

  3. 3

    Turn on the NXT brick and select the View submenu. Select the Reflected Light icon and select the port to which the light sensor is connected. Hold the sensor over the paper and note the reading on the NXT brick screen. Move the sensor over the line you drew in step 2 and note the new reading.

  4. 4

    Create the program for your robot. Program your robot to drive the left wheel forward when the sensor is over the line and the right wheel forward when the sensor is over blank paper. Download the program to your NXT brick.

  5. 5

    Place the robot on the paper with the sensor just to the right of the line. Turn on the NXT brick, select the program you have created in step 4, and run it.

Don't Miss

  • All types
  • Articles
  • Slideshows
  • Videos
  • Most relevant
  • Most popular
  • Most recent

No articles available

No slideshows available

No videos available

By using the site, you consent to the use of cookies. For more information, please see our Cookie policy.