Line follower in one evening

Beginner | about 3 hours

A line follower is a robot that drives along a black line on a white floor. It's the classic first robot because it teaches the three parts of every robot: sensing (where is the line?), thinking (which way to turn?) and moving (turn the wheels).

What you need

  • Line Follower Robot Kit (chassis, two BO motors, Nano, IR array, L298N)
  • Two 18650 cells (7.4V together)
  • A screwdriver and black electrical tape for the track

Step 1: Build the chassis

Screw the two motors under the chassis, push the wheels on, and fit the castor wheel at the front. Put the battery holder on top.

Step 2: Wire the motors

Connect the left motor to OUT1/OUT2 and the right motor to OUT3/OUT4 on the L298N. Battery + goes to 12V, battery − to GND. Join the L298N GND to the Nano GND: every part must share the same ground.

Why a motor driver? A Nano pin gives about 20 mA. A BO motor needs up to 800 mA. The L298N takes the small signal from the Nano and switches the big battery current.

Step 3: Wire the sensor

IR array VCC to Nano 5V, GND to GND, and the five outputs to pins A0 to A4.

Step 4: The code idea

if (middle sensor sees black)  go straight
else if (left side sees black) turn left
else if (right side sees black) turn right

The full sketch is in the printed guide. Adjust the small blue trim pots on the sensor until each LED turns on over black and off over white.

Step 5: Test

Make an oval track with black tape. Start slow, then raise the speed. If the robot turns the wrong way, swap the two wires of that motor.