Arduino Line Follower Robot
Level 10 · Level 10 — Following a Line · 45 minutes
Two infrared eyes and four lines of logic: the first robot that decides where to go by itself.

Preview the project free; a course seat is required to run and submit. No hardware kit needed.
Your project challenge
Make the robot follow the line by itself. Keep Level 9's robot. Add an eye either side of the line: - Left sensor: VCC to 5V, GND to GND, OUT to D5 - Right sensor: VCC to 5V, GND to GND, OUT to D4 Then: both eyes see the line, go straight. One eye only, steer back. Neither, stop.
Components you’ll use
- Arduino Uno
- L298N Motor Driver
- DC Gear Motor × 2
- Battery
- IR Line-Tracking Sensor × 2
What you'll build
The first robot that decides where to go by itself. Two eyes, four lines of logic.
How it works
- Each eye shines infrared at the floor and watches what bounces back.
- Black absorbs almost all of it. White reflects it.
- So "I can see the line" means "almost nothing came back".
- Both eyes on the line: go straight.
- One eye only: you have drifted the other way. Turn toward the eye that still sees it.
- Neither eye: you have lost it. Stop, rather than drive off across the table.
digitalRead(LEFT_EYE) == LOW means "I am on the line".
The key idea
Nothing in your loop() says where to go any more. It reads the world and reacts, which is the whole of what a robot is.
To pass:
- On the line for 90% of the run.
2300 mmof the 2436 mm lap. About 94% of the way round.
⚠ Watch out
LOW means "on the line". Backwards from what most people guess. Test for HIGH and both eyes report nothing, every tick. Your robot takes its "lost it" branch and sits still, parked on the line.
The interactive editor includes the wiring guide, code editor and simulation controls.