Same-day dispatch before 2 PM · Free delivery over ₹999 · GST invoices Get the appPrices incl. GST
Geekobot
Snap & SendNEWGeeko AIWhere's myOrder
Log in
Products
  • Projects
    • Component guidesHow parts work, with code you can run
    • Learning pathsFrom your first LED to your first robot
    • Workshops & eventsOnline sessions for makers and classes
    • ElectrolarkFree guided builds, simulator and certificates
    • Students & teachersStudent discount and classroom help
    • CommunityShare builds and ask other makers
    • CalculatorsOhm's law, LED resistor, 555 and 100+ more
    • Circuit builderWire parts and run the circuit, powered by Electrolark
    • Geeko AIAsk what to buy or how to wire it
    • Snap & SendPhotograph a part or list, we find it
    • Part finderAnswer a few questions, get the right part
    • Compatibility checkWill these two parts work together?
    • Compare partsSpecs side by side
    • Business & bulk ordersGST invoices, credit and volume prices
    • Request a quotationSend your list, get a quote
    • Classroom kitsPer-student kits and lab bundles
    • Gift cardsFor students, teams and events
  • Atal Tinkering Lab
BOM to cart
Geekobot

Components, kits and know-how for makers, students, engineers, labs and businesses across India.

Ask Geeko AIOrders, parts and projects, any timeEmail supportReply within 1 working dayGet the Geekobot appAdd it to your home screen, free

Follow us

Shop

  • Boards & SBCs
  • Sensors & Modules
  • IoT & Wireless
  • Drone & FPV
  • 3D Printing
  • Filaments & Resins
  • Motors & Drivers
  • Power & Batteries
  • Semiconductors
  • Passive
  • Displays & LEDs
  • Switches & Relays
  • Wires & Cables
  • Prototyping
  • Tools & Test
  • Robotics
  • STEM Kits
  • Atal Tinkering Lab
  • Mechanical Parts
  • Audio

Orders

  • Track your order
  • Help & support
  • Shipping and delivery
  • Refunds and cancellation
  • Contact us

Learn

  • Projects
  • Geeko AI project assistant
  • Learning paths
  • Guides
  • Calculators
  • Electrolark: free guided builds

Part tools

  • Part finder
  • Compare parts
  • Will it work with my board?

Institutions

  • Classroom kits
  • Atal Tinkering Lab
  • Students & teachers
  • Workshops & Events

Business

  • Business & education
  • Request a quotation
  • BOM bulk upload
  • Quick order by SKU

Company

  • About Geekobot
  • Community
  • Gift cards
  • Terms & conditions
  • Privacy policy
  • Product directory
  • Sitemap

© 2026 Geekobot, a trade name of OLatus Systems Private Limited. All rights reserved.

20, 1st Floor, Neeladri Complex, 10th Cross, Sampige Rd, 2nd Main, Malleshwaram, Bengaluru, Karnataka 560003 · GSTIN 29AACCO0462F1ZM

+91 91810 15607 · connect@geekobot.in · Monday to Saturday, 10 AM to 2 PM IST

UPI · CARDS · NETBANKING · GST INVOICES

ShopProjectsGeeko AIGuides
Compare 0 parts →
Log in

Shop by category

Shop all components
  • Boards & SBCs1,910 products
    • Alternative Single Board Computers
    • Arduino Ecosystem
    • FPGA & Logic Boards
    • Microcontroller & Wireless Boards
    View all
  • Sensors & Modules4,701 products
    • Biomedical & Heart Rate
    • Current, Voltage & Power
    • Force, Weight & Pressure
    • Gas, Weather & Environmental
    View all
  • IoT & Wireless2,314 products
    • RF Modules
    • RFID & NFC
    • Antennas & RF Accessories
    • Cameras & Smart Vision
    View all
  • Drone & FPV3,558 products
    • Flight Control & Navigation
    • FPV Video & Optics
    • Frames & Structural Parts
    • Motors & Propulsion
    View all
  • 3D Printing2,204 products
    • 3D Printers
    • 3D Scanners & Digitizers
    • Laser Engravers & Cutters
    • Material Management & Upgrades
    View all
  • Filaments & Resins1,472 products
    • Filaments
    • Photopolymer Resins
    View all
  • Motors & Drivers463 products
    • BLDC Motor Drivers
    • DC & Geared Motors
    • DC Motor Drivers
    • Linear Actuators & Solenoids
    View all
  • Power & Batteries557 products
    • Battery Holders & Connectors
    • Breadboard Power
    • Chargers & BMS
    • DC-DC Converters
    View all
  • Semiconductors295 products
    • Diodes & Rectifiers
    • Interface & RF Encoder ICs
    • Logic ICs (74xx)
    • Logic ICs (CD4000)
    View all
  • Passive67 products
    • Capacitors
    • Circuit Protection
    • Crystals & Oscillators
    • Inductors
    View all
  • Displays & LEDs572 products
    • 7-Segment & Dot Matrix
    • Addressable LEDs
    • Character LCDs
    • Graphic LCDs
    View all
  • Switches & Relays184 products
    • Keypads & Touch
    • Push Buttons & Tactile
    • Relay Modules
    • Relays
    View all
  • Wires & Cables233 products
    • Board-to-Wire Connectors
    • Crimp & Splice
    • Headers & Dupont
    • Heat Shrink & Sleeving
    View all
  • Prototyping101 products
    • Breadboards
    • Interface Modules
    • PCBs & Perfboards
    View all
  • Tools & Test717 products
    • Bench Power Supplies
    • Hand Tools
    • Measuring Tools
    • Meters & Testers
    View all
  • Robotics180 products
    • Humanoid & Legged Robots
    • Robot Chassis & Platforms
    • Robotic Arms & Grippers
    • Wheels & Casters
    View all
  • STEM Kits268 products
    • Arduino Learning Kits
    • Coding & IoT Kits
    • Early Coding (Ages 3-8)
    • Invention Kits
    View all
  • Atal Tinkering Lab196 products
    • Package 1: Electronics, Robotics, IoT and Sensors
    • Package 2: Rapid Prototyping Tools
    • Package 3: Mechanical, Electrical and Measurement Tools
    • Package 4: Power Supply, Accessories and Safety Equipment
    View all
  • Mechanical Parts212 products
    • Bearings
    • Brackets & Mounts
    • Couplers
    • Fasteners & Standoffs
    View all
  • Audio109 products
    • Amplifier Modules
    • Buzzers & Sirens
    • Speakers
    View all
  1. Home
  2. ›Guides
  3. ›Robotics
  4. ›Line Follower Robot
Step 14 of 16 in Motors and robotsPart of a learning path.
Next

How-to · Intermediate · 3 min read

Line Follower Robot

Sensors, Wiring and Control Logic

By Geekobot Learning Team · Updated 24 Oct 2026

I'm using
Wiring, code and the Run it panels follow your board.
On this page
Short answerParts listHow the sensors see the lineSimple three-sensor logicArduino code: three sensors, bang-bang controlSmoother and faster: PID with a 5-sensor arrayTuning and troubleshootingTry itCommon mistakesFAQsParts and next steps
Short answer

A line follower uses a row of infrared reflective sensors (TCRT5000 type) under the robot to see a black line on a white floor, and steers two DC motors to keep the line centred. Start with two or three sensors and simple left/right logic, then move to a 5-sensor array and PID control for smooth, fast following. Power the motors through a driver from their own battery.

Key specs at a glance

Sensors
2 to 8 TCRT5000 reflective IR sensors, 5 to 15 mm above the floor
Motors
2 x BO or N20 gear motors, 100 to 300 RPM
Driver
TB6612FNG or L298N
Controller
Arduino Uno/Nano or ESP32
Power
2S Li-ion (7.4 V) or 6 x AA for motors; shared ground with the controller
Line
Black tape 18 to 25 mm wide on white, or the reverse
01

Parts list

Shop this list3 of 4 found in our store · ₹71,309

  • A 2WD chassis with two BO motors and a caster, or an N20-based mini chassis.Round 2WD Mini Robot Chassis₹379Closest match, check the specs
  • 2, 3 or 5 TCRT5000 sensor modules, or a Cytron LSS05 / Pololu QTR-5 array.Find this part
  • A motor driver: TB6612FNG for N20 and BO motors on 6 to 8 V, L298N for 12 V motors.TB6612FNG Dual Motor Driver Module₹130Closest match, check the specs
  • An Arduino Uno or Nano (or ESP32), a 2S Li-ion pack or 6 x AA, and jumper wires.Kikobot C1 6-Axis Robotic Arm for Education and Research₹70,800
02

How the sensors see the line

Each TCRT5000 shines IR at the floor and measures the reflection. White reflects strongly, black tape reflects little. The module's comparator outputs HIGH or LOW (the direction depends on the module) and most also give an analog value. Mount the sensors 5 to 15 mm above the floor, spaced slightly narrower than the line so at least one sensor sees the line in a turn.

03

Simple three-sensor logic

LeftCentreRightAction
WhiteBlackWhiteDrive straight
BlackBlackWhiteTurn left (slow left motor)
BlackWhiteWhiteTurn left hard
WhiteBlackBlackTurn right
WhiteWhiteBlackTurn right hard
WhiteWhiteWhiteLost: keep last turn, or stop
BlackBlackBlackJunction or finish line: stop or count
White
Centre:
Black
Right:
White
Action:
Drive straight
Black
Centre:
Black
Right:
White
Action:
Turn left (slow left motor)
Black
Centre:
White
Right:
White
Action:
Turn left hard
White
Centre:
Black
Right:
Black
Action:
Turn right
White
Centre:
White
Right:
Black
Action:
Turn right hard
White
Centre:
White
Right:
White
Action:
Lost: keep last turn, or stop
Black
Centre:
Black
Right:
Black
Action:
Junction or finish line: stop or count
04

Arduino code: three sensors, bang-bang control

Three-sensor line follower · Arduino C++Verify & upload in Electrolark
const int L = A0, C = A1, R = A2;          // sensor digital outputs
const int ENA = 5, IN1 = 7, IN2 = 8;       // left motor
const int ENB = 6, IN3 = 9, IN4 = 10;      // right motor
const int BASE = 150;                      // 0 to 255

void motors(int left, int right) {
  digitalWrite(IN1, left >= 0);  digitalWrite(IN2, left < 0);
  digitalWrite(IN3, right >= 0); digitalWrite(IN4, right < 0);
  analogWrite(ENA, abs(left)); analogWrite(ENB, abs(right));
}

void setup() {
  for (int p : {L, C, R}) pinMode(p, INPUT);
  for (int p : {ENA, IN1, IN2, ENB, IN3, IN4}) pinMode(p, OUTPUT);
}

void loop() {
  bool l = digitalRead(L) == LOW;   // LOW on black for most TCRT5000 modules
  bool c = digitalRead(C) == LOW;
  bool r = digitalRead(R) == LOW;
  if (c && !l && !r)      motors(BASE, BASE);
  else if (l)             motors(BASE / 3, BASE);
  else if (r)             motors(BASE, BASE / 3);
  else                    motors(BASE / 2, BASE / 2);   // lost: creep forward
}
05

Smoother and faster: PID with a 5-sensor array

With five analog sensors, compute a weighted position from -2000 to +2000 (0 = centred). Error = position; correction = Kp x error + Kd x (error - lastError). Left speed = base - correction, right = base + correction. Start with Kp around 0.05 and Kd = 0, raise Kp until the robot oscillates, then add Kd (10 to 20 x Kp) to damp it. Ki is rarely needed. Calibrate by sweeping the robot across the line at start-up and storing each sensor's min and max.

06

Tuning and troubleshooting

Robot wobbles

base speed too high for the logic; lower it or add PID.

Loses the line in curves

sensors too far apart, or too fast. Space them closer and slow on sharp turns.

Random readings

sunlight or glossy floors. Shield the sensors and test on matte white paper.

One motor slower

motors differ; add a trim value, or use encoders.

Resets when motors start

shared weak battery; add a capacitor on the driver supply or separate the supplies.

07

Try it: Wheel speed calculator

Change the values and the diagram and results update as you type.

08

Common mistakes to avoid

  • !Mounting sensors too high or too far apart.
  • !Running the Arduino and motors from a 9 V PP3 battery.
  • !Hard-coding thresholds instead of calibrating on the actual floor.
  • !Driving straight at full speed with bang-bang control.
  • !Ignoring the sensor module's polarity (LOW vs HIGH on black).
09

Frequently asked questions

Which sensor is best for a line follower?

TCRT5000 reflective sensors, either as separate modules or a 5-channel array such as the Cytron LSS05 or Pololu QTR-5A. Arrays make PID control easier.

How many sensors does a line follower need?

Two or three for a basic robot; five or more for fast, smooth following and junction detection.

What motors should I use?

Geared DC motors at 100 to 300 RPM: BO motors for cheap chassis, N20 micro metal gear motors for small fast robots. Match the driver to the stall current.

Does a line follower need PID?

Not for a start. Simple left/right logic works. PID makes it faster and smoother, which matters in competitions.

Why does my line follower work on paper but not on the floor?

Floor reflectivity differs: glossy or dark floors confuse IR sensors. Calibrate on the real surface and shield the sensors from ambient light.

Parts for this guide

  • DIY Line Follower Robot Kit
    ₹240View
  • Cytron Technologies LSS05 Auto-Calibrating Line Sensor Module for Robotics – 5-Channel IR Array
    ₹1,039View
  • TCRT5000 Dual Channel Line Tracking Sensor Module – Infrared Reflective Detection
    ₹36View
  • 2WD Smart Robot Car Chassis Kit
    ₹293View
  • TB6612FNG Dual Motor Driver Module
    ₹130View
Shop Robot Chassis & PlatformsShop Light & Optical SensorsShop Robot Kits

Calculators

Wheel speed calculatorGear ratio calculatorBattery life calculator

Terms in this guide

PIDProportional-integral-derivative control: a feedback loop that steers towards a target smoothly by combining the current error, its history and its rate of change.InfraredLight just beyond red that people cannot see, used by IR obstacle sensors, remote controls and line-following sensors.PWMPulse-width modulation: switching a signal on and off quickly so its average sets brightness, speed or position.H-bridgeA circuit of four switches that can drive a motor in both directions.CalibrationMeasuring a sensor against known conditions so its raw numbers can be converted into meaningful values, such as dry and wet readings for a soil sensor.Stall currentThe current a motor draws when its shaft is blocked; the maximum it will draw.

Projects that use it

Put this into practice: 35 step-by-step builds in our project library use parts from this guide.

Intermediate · 3–4 hoursLine follower robot with L298N and TCRT5000View projectIntermediate · 3–4 hoursObstacle-avoiding robotView projectIntermediate · 3 hoursTable-edge avoiding robotView project
Browse all 35 projects

Keep learning

Component guideBeginnerIR Obstacle Sensor ModuleAn IR obstacle sensor module shines infrared light from an LED and watches for its reflection with a photodiode; when something is within about 2 to 30 cm, its OUT pin goes LOW.3 min read · SensorsComponent guideBeginnerDC Motors ExplainedA brushed DC motor spins when current flows through it: voltage sets the speed and the load sets the current it draws.4 min read · Motors & MotionComparisonBeginnerMotor Drivers ExplainedA motor driver lets a low-power microcontroller control the speed and direction of motors using an H-bridge.4 min read · Motors & MotionComponent guideBeginnerArduino UnoThe Arduino Uno is a beginner-friendly microcontroller board that reads sensors and controls LEDs, motors and relays using simple C++ programs called sketches.5 min read · Boards & MicrocontrollersComponent guideBeginnerLi-ion, 18650 and LiPo BatteriesLithium-ion cells, including 18650s and flat LiPo packs, store about 3.6 to 3.7 V nominal, charge to exactly 4.2 V and should not be discharged below about 3.0 V.4 min read · Power & Batteries

Sources

  • TCRT5000 datasheet (Vishay)
  • Pololu QTR sensor library documentation
  • Cytron LSS05 user manual

Written by the Geekobot team from manufacturer datasheets. Always check the datasheet for the exact part and variant you buy.

On this page
Short answerParts listHow the sensors see the lineSimple three-sensor logicArduino code: three sensors, bang-bang controlSmoother and faster: PID with a 5-sensor arrayTuning and troubleshootingTry itCommon mistakesFAQsParts and next steps
Need a hand?Ask Geeko AI which part fits your project, or talk to the Geekobot team.Ask Geeko AIHelp & support

Parts for this guide1 item · ₹70,800

Kikobot C1 6-Axis Robotic Arm for Education and Research

Run itChange the inputs and watch the output
Left wheel fwd 59%
Right wheel fwd 59%
straightRobot

A simulation of the sketch above, so you know what to expect. Real readings vary with your parts and wiring.

Ask the Community

Ask a question