Jump to main content

Line-Following Robot


Grade Range
Group Size
2-4 students
Active Time
2-3 hours
Total Time
2-3 hours
Area of Science
Key Concepts
Circuits, electromagnetic spectrum
Ben Finio, PhD, Science Buddies
Line-Tracking Robot: BlueBot Project #3


Have your students read about autonomous (also called self-driving or driverless) cars in the news? How can you build a car or a robot that will stay on the road without a human driver? In this project, your students will find out by building a robot that can automatically follow a line around a homemade race course, while learning about the electromagnetic spectrum and electronic circuits.

Learning Objectives

NGSS Alignment

This lesson helps students prepare for these Next Generation Science Standards Performance Expectations:
This lesson focuses on these aspects of NGSS Three Dimensional Learning:

Science & Engineering Practices Disciplinary Core Ideas Crosscutting Concepts
Science & Engineering Practices Planning and Carrying out Investigations. Collect data to produce data to serve as the basis for evidence to answer scientific questions or test design solutions under a range of conditions.

Analyzing and Interpreting Data. Analyze and interpret data to provide evidence for phenomena.
Disciplinary Core Ideas PS4.B: Electromagnetic Radiation. When light shines on an object, it is reflected, absorbed, or transmitted through the object, depending on the object's material and the frequency (color) of the light.
Crosscutting Concepts Structure and Function. Structures can be designed to serve particular functions by taking into account properties of different materials, and how materials can be shaped and used.


Parts from a BlueBot robotics kit sold on the website homesciencetools.com are laid out neatly

Disclaimer: Science Buddies participates in affiliate programs with Home Science Tools, Amazon.com, Carolina Biological, and Jameco Electronics. Proceeds from the affiliate programs help support Science Buddies, a 501(c)(3) public charity, and keep our resources free for everyone. Our top priority is student learning. If you have any comments (positive or negative) related to purchases you've made for science projects from recommendations on our site, please let us know. Write to us at scibuddy@sciencebuddies.org.

Background Information for Teachers

This section contains a quick review for teachers of the science and concepts covered in this lesson.

This project provides a very simplified introduction to how real-world autonomous (also called driverless or self-driving) cars work. Autonomous cars need to navigate a very complicated environment, including reacting to other cars, driving on roads with different types of lines (or no lines at all), and obeying all traffic signals and signs. They do this using a variety of electronic sensors, like cameras and radar, with computers to process all the information. The robot your students will build in this project uses two electronic sensors to automatically follow a dark line on a white background. This is conceptually similar (but not identical) to how a real autonomous car might monitor lane lines to make sure the car does not drift out of its lane.

The robot uses infrared (IR) light sensors. Infrared light is part of the electromagnetic spectrum, just outside the range of human vision. Each sensor contains an infrared emitter, which sends out infrared light, and an infrared detector, which measures whether infrared light is bounced back. Just like the colors of visible light that we can see, and all other types of electromagnetic radiation, infrared light is reflected by some surfaces, and absorbed or transmitted by others. The sensors have a very short range (a few millimeters), which means they can be used to detect nearby objects that reflect infrared light, as shown in Figure 1.

Diagram of an infrared light sensor that can detect light bounced off of bright surfaces but not dark surfaces

A sensor for the line-following robot consists of an infrared emitter and an infrared detector. When the IR emitter shines a light on a bright surface the reflection is bounced into the IR detector. When the IR emitter shines a light on a dark surface, the IR light is absorbed and does not reflect any light towards the IR detector. When the IR detector doesn't detect any IR light then the sensor knows it is on a dark surface.

Figure 1. Schematic of the IR light sensors.

The robot drives by using two sensors and differential steering, meaning it has two wheels that are driven independently by two different motors (unlike a car, which has a steering wheel that turns both front wheels). When both wheels spin, the robot drives forward. When the left sensor sees a dark surface, the left wheel stops and the right wheel keeps spinning, so the robot turns left (and vice versa for the right sensor). That means the robot can follow a line, as shown in Figure 2.

Diagram of a line-following robot using light sensors to turn or remain on a straight path

Two infrared sensors are placed on the front of a line-following robot chassis and spaced apart slightly wider than the width of the black line. As the two sensors scan either side of a black line the light will be reflected off the white surface and the sensors will send power to the motors. When a line begins to curve left, the left IR sensor will detect the dark surface and cut power to the left wheels which cause the robot to begin turning towards the left. When the robot is turned far enough left that the sensor is no longer over the black line, than the left motor will receive power again. The same situation applies for a line curving right and the right IR sensor and motor.

Figure 2. Following a line with two IR sensors.

The robot's circuit contains other electronic components like resistors, transistors, and diodes that allow the sensors to control the motors. You do not need to understand exactly how the circuit works in order to build it and do the project. For a detailed technical explanation of how the circuit works, including a circuit diagram, see this page.

This project requires use of a breadboard, a tool for quickly and easily prototyping electronic circuits. If you have never used a breadboard before, we highly recommend watching the following video before doing the activity with your class. There are several common mistakes that students make when using breadboards, and being familiar with them will help you facilitate troubleshooting during class. You can also ask your students to watch the video as a homework assignment before class.

How to Use a Breadboard

Prep Work (20 minutes)

Engage (10 minutes)

Explore (120 minutes)

Reflect (10 minutes)


Make Career Connections

Lesson Plan Variations

Free science fair projects.