All Activities

Make a robot follow a line

Make a robot follow a line
Green highlight

Build a simple line-following robot using motors, sensors, and a battery. Assemble parts, program basic logic, and test on a track.

Orange shooting star
Background blob
Challenge Image
Skill Badge
Table of contents

Step-by-step guide to make a robot follow a line

0:00/0:00

Here at SafeTube, we're on a mission to create a safer and more delightful internet. 😊

DIY Line Following Robot Using Arduino - Let's Build Your First Robot!

What you need
Small dc motors with wheels, motor driver module l293d or l298n, microcontroller board like arduino, battery pack and batteries, two reflectance line sensors, breadboard and jumper wires, cardboard or small plastic chassis, hot glue or strong tape, small bottle cap or pen cap for front support, black electrical tape to make a track, scissors and marker, adult supervision required

Step 1

Clear a flat workspace and lay out all the materials so everything is easy to grab.

Step 2

Cut a hand sized rectangle from the cardboard to make the robot chassis base.

Step 3

Attach the two DC motors to the rear corners of the chassis using hot glue or strong tape.

Step 4

Push the wheels onto the motor shafts until they fit snugly.

Step 5

Stick the bottle cap or pen cap near the front center of the chassis to act as a front support.

Step 6

Secure the motor driver module and the microcontroller board onto the chassis with tape or glue.

Step 7

Use jumper wires to connect the two motors to the motor driver output pins.

Step 8

Connect the motor driver power and ground to the battery pack and make sure the microcontroller ground is shared with the driver ground.

Step 9

Mount the two reflectance line sensors at the front of the chassis about one centimeter above the ground and secure them with tape.

Step 10

Wire each sensor to the microcontroller inputs and to the power and ground pins on the breadboard.

Step 11

Use a computer to upload a simple program that reads both sensors and drives the motors so the robot moves forward on light surface and turns away from dark line signals.

Step 12

Make a test track by laying a wide strip of black electrical tape on a light floor to form a line for the robot to follow.

Step 13

Place the robot on the track and power it on to see how it reacts to the line.

Step 14

Adjust the sensor height or tweak the code thresholds until the robot reliably follows the black line.

Step 15

Take a photo or video and share your finished line following robot on DIY.org

Help!?

I can't find reflectance line sensors or the exact motor driver—what can I use instead?

If you don't have reflectance sensors or the named motor driver module, substitute homemade IR LED + phototransistor sensor pairs for the reflectance sensors and use an L293D H-bridge chip or a two-channel motor shield in place of the motor driver while using toy DC motors and bottle-cap wheels as described in the steps.

The robot won't follow the line or doesn't move reliably—what should I check?

If the robot doesn't move or veers off, first verify the motor driver power and ground are connected to the battery pack and that the microcontroller ground is shared with the driver ground, then check jumper wire connections, ensure the wheels are pushed snugly onto the motor shafts, and adjust sensor height or tweak the code thresholds as instructed.

How can I adapt this activity for different age groups?

For preschoolers have an adult pre-cut the cardboard chassis and attach motors and sensors while letting the child place the tape track and position the robot, for elementary kids let them assemble the motors, mount sensors, and upload block-style code, and for teens add challenges like multiple sensor arrays and PID tuning of the code thresholds.

What are simple ways to extend or personalize the line-following robot?

Enhance the project by adding LED indicators to show each reflectance sensor state, mounting a Bluetooth module to control or log runs from a phone, creating an adjustable sensor mount to fine-tune height, or expanding the track with branches to program decision-making behavior before sharing your photo or video.

Watch videos on how to make a robot follow a line

0:00/0:00

Here at SafeTube, we're on a mission to create a safer and more delightful internet. 😊

How to make a Line Following Robot || Arduino Project || Line follower robot making tutorial

4 Videos
How to make a Line Following Robot || Arduino Project || Line follower robot making tutorial

How to make a Line Following Robot || Arduino Project || Line follower robot making tutorial

【Tutorial】How to Create a LEGO Line-Following Robot: Full Tutorial

【Tutorial】How to Create a LEGO Line-Following Robot: Full Tutorial

How to Make a Line Follower Robot Car with Arduino UNO, L298N Motor Driver, IR Sensor

How to Make a Line Follower Robot Car with Arduino UNO, L298N Motor Driver, IR Sensor

Line Following Robot without Microcontroller || DIY|| Engineering

Line Following Robot without Microcontroller || DIY|| Engineering

Facts about robotics and electronics for kids

🤖 The simplest line-following robots date back to hobbyist kits from the 1980s and often used just two light sensors and two motors.

🔋 Many beginner line-followers run on 2–4 AA batteries or a single small rechargeable Li-ion/LiPo pack for lightweight power.

🕹️ The Arduino platform became popular with makers because its easy programming and many libraries make controlling sensors and motors simple.

⚙️ Most small line-followers use differential drive (two independent wheels) so they turn by changing each wheel's speed.

🎯 Using a PID controller instead of simple on/off logic lets a robot follow curves more smoothly and accurately.

How do I build a simple line-following robot?

Start by choosing a small chassis and mounting two drive motors with wheels. Connect the motors to a motor driver and wire that to a microcontroller (Arduino, micro:bit, or similar). Mount one or two line sensors near the front, connect a battery pack with a switch, then upload simple logic: read left/right sensors and steer (left sensor sees line → turn left, right sensor sees line → turn right, both → go forward). Test on black tape track and tune sensor thresholds and motor speed.

What materials do I need to build a line-following robot?

You’ll need a small robot chassis, two DC motors with wheels, a motor driver (L293D, TB6612, etc.), a microcontroller (Arduino, micro:bit, or Raspberry Pi Pico), line sensors (IR reflectance sensors or a QTR array), a battery pack and connector, jumper wires, breadboard or soldering tools, and mounting hardware. Optional: caster wheel, speed controller, encoder wheels, spare batteries, and a roll of black tape for the track.

What ages is this line-following robot activity suitable for?

This activity suits ages 8+ with adult help for wiring and programming. Children 10–14 can often handle assembly and basic coding with guidance; teens (14+) can complete it independently and explore advanced tuning. For younger kids (5–7), offer a simplified kit or let them help with testing and sensor placement while an adult does soldering and electronics.

What safety tips should I follow when building and testing a line-following robot?

Use low-voltage batteries and check polarity before powering. Avoid short circuits, secure loose wires, and insulate solder joints. Always supervise soldering and hot tools. Keep hair and loose clothing away from moving wheels, test on a cleared surface, and turn off power when adjusting components. Let motors cool if they get hot and store batteries safely. Teach children to cut power immediately if the robot behaves unpredictably.

Ready to create?

Drop Files here
Make

To create a safe space for kid creators worldwide!

Create

Vibe Coding

Kids GPT

All Tools

Kibu

Resources

Worksheets

SafeTube

Blog

FAQ

Account

Pricing

Log-in

Sign-up

Data Deletion

Company

About

Community Guidelines

Privacy Policy

Terms of Service

2025, URSOR LIMITED. All rights reserved. DIY is in no way affiliated with Minecraft™, Mojang, Microsoft, Roblox™ or YouTube. LEGO® is a trademark of the LEGO® Group which does not sponsor, endorse or authorize this website or event. Made with love in San Francisco.