
Competition line follower robot
Build a line follower that wins
A light, fast line follower with a 5-sensor IR array, an Arduino Nano, two N20 metal-gear motors and a TB6612 driver, steered by PID code that takes curves smoothly. Built for university robotics competitions.
Every required part
Rs 5,458
Parts list
21 items
- Every required part in stock
- Wiring and code included
- Cash on delivery
From our reel · 18 Dec 2026Parts list
Everything you need for the competition line follower robot
Required parts are ticked. Untick anything you already have; the total updates as you go.
Main parts
- Rs 540Required5 Channel TCRT5000 IR Array Tracking Sensor Module
Five eyes that see black and white; comes with its cable.
1Rs 540 each - Rs 660RequiredArduino Nano V3
Small and light. Its pins may need soldering; pick the pre-soldered one if you cannot solder.
1Rs 660 each - Rs 450RequiredTB6612 Dual Motor Driver 1A TB6612FNG for Arduino Microcontroller
Small and efficient: loses far less voltage than an L298N, so the motors stay fast.
1Rs 450 each - Rs 300Required9cm x 15cm Double Sided FR4 Fiber Glass Dotted Veroboard
Light and stiff; competition robots often use a board as the chassis.
1Rs 300 each
Power
- Rs 400RequiredUniversal Double Slots Li-ion Battery Charger for 18650 Cells 3.7v Rechargeable Lithium Ion Batteries
Untick it if you already have one.
1Rs 400 each
Wiring & mounting
- Rs 160RequiredSyb-170 Solderless Mini Breadboard
One for the Nano, one for the motor driver.
2Rs 80 each - Rs 170Required20cm Pin To Hole Jumper Wire Dupont Line 40 Pin Male To Female Arduino Jumper Wires1Rs 170 each
- Rs 150Required10cm Pin To Pin Jumper Wire Dupont Line 40 Pin Male To Male Arduino Jumper Wires1Rs 150 each
Tools
- Rs 410OptionalHot Melt ABC-E15W Glue Gun For 7mm Glue Rod
Fastest way to fix the motor brackets and caster firmly.
1Rs 410 each - Rs 459OptionalSoldering Iron Vhan 40W Solder
Only if the Nano's or driver's header pins come loose.
1Rs 459 each
Optional upgrades
- Rs 600Optional8 Channel Reflectance Sensor Array Module Qtr-8A
Upgrade for very fast tracks: eight analog sensors for finer steering.
1Rs 600 each
You also need (most homes have these)
- A practice trackBlack electrical tape (about 19 mm) on a white chart sheet or floor tiles.
17 items
Rs 5,458
From our reel
Watch it come together in 12 steps
The reel of this build goes live on 18 Dec 2026, 7 pm. Follow us to watch it:
YouTube Instagram Facebook
1The parts

2The competition track

3Mount the motors

4IR sensor array up front

5Brain + motor driver

6Wire it up

7Calibrate black & white

8Upload PID code

9Smooth on the curves

10Full speed!

11Team goes wild

12Trophy time
How it works
What each part does
Each IR sensor shines infrared light down and checks whether it bounces back: white reflects, black absorbs. The five readings tell the Nano where the line is, from far left (−2) to far right (+2).
PID control turns that position error into steering. The P part steers harder the further the line is off-centre, and the D part reacts to how fast the error changes, which damps the wobble. One wheel speeds up while the other slows down, so the robot glides through curves instead of jerking.
When the line disappears, the robot keeps turning the way it last saw it, which brings it back onto sharp bends.
Wiring
Connect it pin by pin
Sensors
| From | To | Note |
|---|---|---|
| IR array VCC / GND | → Nano 5V / GND | |
| IR array OUT1 … OUT5 (left to right) | → Nano A0 … A4 |
Motor driver (TB6612FNG)
| From | To | Note |
|---|---|---|
| STBY | → Nano D4 | |
| PWMA / AIN1 / AIN2 | → Nano D5 / D7 / D8Left motor | |
| PWMB / BIN1 / BIN2 | → Nano D6 / D9 / D10Right motor | |
| A01 / A02 | → Left motor | |
| B01 / B02 | → Right motor | |
| VCC | → Nano 5V | |
| VM | → Battery + (after the switch) | |
| GND | → Battery − and Nano GND |
Power
| From | To | Note |
|---|---|---|
| Battery + → switch | → Nano VIN and TB6612 VM | |
| Battery − | → Nano GND and TB6612 GND |
The code
Ready-to-upload Arduino code
const int SENSORS[5] = {A0, A1, A2, A3, A4}; // left to right
const int PWMA = 5, AIN1 = 7, AIN2 = 8; // left motor
const int PWMB = 6, BIN1 = 9, BIN2 = 10; // right motor
const int STBY = 4;
const int BASE = 150; // base speed (0-255)
const float KP = 35, KD = 18; // tune these on your track
int lineLevel; // what a sensor reads over the line (HIGH or LOW)
float lastError = 0;
void motor(int pwmPin, int in1, int in2, int speed) {
speed = constrain(speed, -255, 255);
digitalWrite(in1, speed >= 0);
digitalWrite(in2, speed < 0);
analogWrite(pwmPin, abs(speed));
}
void setup() {
for (int pin : SENSORS) pinMode(pin, INPUT);
pinMode(PWMA, OUTPUT); pinMode(AIN1, OUTPUT); pinMode(AIN2, OUTPUT);
pinMode(PWMB, OUTPUT); pinMode(BIN1, OUTPUT); pinMode(BIN2, OUTPUT);
pinMode(STBY, OUTPUT);
digitalWrite(STBY, HIGH);
// Switch on with the middle sensor over the line: whatever it reads now means "line".
lineLevel = digitalRead(SENSORS[2]);
delay(1000);
}
void loop() {
const int weights[5] = {-2, -1, 0, 1, 2};
int sum = 0, count = 0;
for (int i = 0; i < 5; i++) {
if (digitalRead(SENSORS[i]) == lineLevel) {
sum += weights[i];
count++;
}
}
float error;
if (count == 0) error = lastError > 0 ? 2.5 : -2.5; // line lost: keep turning the way it went
else if (count == 5) error = 0; // crossing: go straight
else error = (float)sum / count;
float correction = KP * error + KD * (error - lastError);
lastError = error;
motor(PWMA, AIN1, AIN2, BASE + correction);
motor(PWMB, BIN1, BIN2, BASE - correction);
delay(5);
}Step by step
Build it
- 1
Lay out the chassis
Fix the two motor brackets at the back corners of the board, the caster at the front centre, and the sensor bar at the very front, about 3 to 5 mm above the floor.
- 2
Add the electronics
Stick the two mini breadboards in the middle: the Nano on one, the TB6612 on the other. Put the battery holder and switch between the wheels to keep the weight low and central.
- 3
Wire it
Follow the tables. Motors go to A01/A02 and B01/B02; all grounds join. The battery feeds both the Nano's VIN and the driver's VM through the switch.
- 4
Upload the code
Upload with the battery switched off. Then place the robot with the middle sensor exactly over the black line and switch on: it learns what “line” looks like at power-up.
- 5
Tune the PID
Start with BASE 100, KP 25, KD 0. Raise KP until it follows curves, add KD until the wobble stops, then raise BASE for speed. Change one number at a time.
Tips & troubleshooting
- If a wheel turns backwards, swap that motor's two wires on the driver.
- If it turns away from the line, swap the left and right motor wire pairs.
- Each sensor on the array has a small blue trimmer: adjust it so its LED switches cleanly between white and black.
- Lighter is faster: trim long wires and keep the battery close to the wheels.
Stuck on wiring or code?
Send us a photo of your build on WhatsApp. We are makers too, and we will help you get it working.
FAQ
Questions people ask
Why not an L298N?+
The L298N loses about 2 V and is heavy. The TB6612 loses very little, so the same battery gives faster motors, and it weighs a few grams.
My robot oscillates left and right on straights.+
KP is too high or KD too low. Lower KP a little, then raise KD until the wobble stops.
Can it handle 90° turns?+
Yes, the “line lost” rule turns it back onto sharp corners. For very fast tracks, upgrade to the QTR-8A array in the parts list.
Read next
- FYP Electronics Parts List: How to Plan, Budget and Buy Your Final Year Project PartsA step-by-step method for Pakistani students to plan final-year-project electronics: block diagram, compatibility checks, power budget and two complete parts lists with live prices.
- Breadboard Price in Pakistan: Which Size to Buy and How It WorksBreadboard prices in Pakistan for every size, from the 170-point mini to 830 and 1660-point boards, which one fits your project, how the holes are connected inside, and the mistakes behind loose connections.
More projects to build
All projects


Pick-and-place robot arm
Build a robot arm that picks things up
All parts
Rs 6,508
3 to 4 hours
11 items

























