Component guide · Beginner · 3 min read
TCRT5000 IR Line Sensor

Pinout, Wiring and Code
By Geekobot Learning Team · Updated 29 Oct 2026
On this page
The TCRT5000 is a reflective infrared sensor: an IR LED and a phototransistor side by side. On a module with an LM393 comparator it gives a digital output that changes between a white and a black surface, which is how line-following robots find the line. It works best 1 to 3 mm from the surface and runs from 3.3 to 5 V.
Key specs at a glance
- Sensor
- TCRT5000 IR LED (950 nm) and phototransistor
- Best distance
- About 1 to 3 mm (peak 2.5 mm), usable up to about 1.5 cm
- Output
- Digital (LM393 comparator), some modules also analog
- Supply
- 3.3 to 5 V
- Channels
- Single, dual or 3-channel modules
- Adjustment
- Trim pot sets the threshold
Models in this guide
These are alternatives. Pick the one that fits your project; you only need one.
Option 1TCRT5000 IR Tracking Sensor Module – Digital Output, 5V₹43
Option 2TCRT5000 Single Channel Line Tracking Sensor Module₹41
Option 3TCRT5000 Dual Channel Line Tracking Sensor Module – Infrared Reflective Detection₹36
Option 4TCRT5000 3-Channel Line Tracking Sensor Module – 5V DC Digital Output₹125
What the TCRT5000 sensor is
White surfaces reflect infrared light and black surfaces absorb it. The TCRT5000 shines IR down and measures how much comes back. The module's comparator turns that into a clean digital signal, with an LED that lights when the output switches.
Its daylight filter makes it less sensitive to room light than a bare IR LED and photodiode, but strong sunlight still affects it.
TCRT5000 sensor pinout
The pins on the TCRT5000 sensor and what each one does.
| Pin | Function |
|---|---|
| VCC | Supply, 3.3 to 5 V |
| GND | Ground |
| D0 / OUT | Digital output (one per channel on multi-channel boards) |
| A0 | Analog output on modules that have it |
- VCC
- Supply, 3.3 to 5 V
- GND
- Ground
- D0 / OUT
- Digital output (one per channel on multi-channel boards)
- A0
- Analog output on modules that have it
Wiring the TCRT5000 sensor
Most modules pull the output LOW when they see a reflective (white) surface and HIGH over black, but check yours: the on-board LED shows the state. Mount the sensors 1 to 3 mm above the track.
| TCRT5000 sensor pin | Arduino Uno | ESP32 |
|---|---|---|
| VCC | 5V | 3V3 |
| GND | GND | GND |
| OUT (left) | D2 | GPIO 25 |
| OUT (centre) | D3 | GPIO 26 |
| OUT (right) | D4 | GPIO 27 |
- VCC
- Arduino Uno:
- 5V
- ESP32:
- 3V3
- GND
- Arduino Uno:
- GND
- ESP32:
- GND
- OUT (left)
- Arduino Uno:
- D2
- ESP32:
- GPIO 25
- OUT (centre)
- Arduino Uno:
- D3
- ESP32:
- GPIO 26
- OUT (right)
- Arduino Uno:
- D4
- ESP32:
- GPIO 27
Example code
Replace the Serial prints with your motor driver commands, for example from the L298N guide.
const int L = 2, C = 3, R = 4;
void setup() {
Serial.begin(115200);
pinMode(L, INPUT); pinMode(C, INPUT); pinMode(R, INPUT);
}
void loop() {
// HIGH = black line under the sensor on most modules
bool l = digitalRead(L), c = digitalRead(C), r = digitalRead(R);
if (c && !l && !r) Serial.println("forward");
else if (l) Serial.println("turn left");
else if (r) Serial.println("turn right");
else Serial.println("line lost: stop");
delay(50);
}Setup and tuning
hold the sensor at its working height over white, then over black, and turn the pot until the LED switches cleanly between the two.
1 to 3 mm gives the sharpest difference; a skid or caster keeps the height constant.
a black shroud around the sensor reduces errors from room lights and sunlight.
read A0 to tune the threshold in code, or to follow the line edge smoothly.
What you need
Shop this list6 of 7 found in our store · ₹420
TCRT5000 single-channel module: for one-sensor detectors and countersTCRT5000 Single Channel Line Tracking Sensor Module₹41Closest match, check the specs
TCRT5000 Single Channel Line Tracking Sensor Module: another version this guide coversTCRT5000 Single Channel Line Tracking Sensor Module₹41
TCRT5000 Dual Channel Line Tracking Sensor Module – Infrared Reflective Detection: another version this guide coversTCRT5000 Dual Channel Line Tracking Sensor Module – Infrared Reflective Detection₹36
TCRT5000 3-channel line tracking module: the sensor this guide coversTCRT5000 3-Channel Line Tracking Sensor Module – 5V DC Digital Output₹125Closest match, check the specs- Uno R3 development board: the controller used in the wiring tableFind this part
L298N motor driver: to drive the robot's motorsL298N Dual H-Bridge Motor Driver Module₹128Closest match, check the specs
Dupont jumper wires: for the connectionsDupont Jumper Wires (40 pcs)₹49Closest match, check the specs
Alternatives and when to choose them
- IR obstacle sensor module: longer range (several cm) for obstacles, not lines.
- Line follower robot: the full build with motors and PID.
- Photointerrupters: slot sensors for encoders and end stops.
Common mistakes to avoid
- Mounting the sensor too high (over about 1 cm), so black and white look the same.
- Testing in sunlight, which floods the receiver.
- Not setting the threshold pot for your track and height.
- Assuming the output polarity without checking the on-board LED.
Frequently asked questions
How far can the TCRT5000 detect?
It works best at 1 to 3 mm and reliably up to about 1.5 cm on white surfaces.
Does it work with 3.3 V boards?
Yes, power it from 3.3 V for a 3.3 V output.
Is the output HIGH on black?
On most modules yes, but check the LED on yours.
Can it detect colours?
Only light versus dark. Use a colour sensor such as the TCS34725 for colours.
How many sensors does a line follower need?
Two work for simple tracks, three or five for smoother control and junctions.
Parts for this guide
Projects that use it
Put this into practice: 11 step-by-step builds in our project library use parts from this guide.
Keep learning
Sources
Written by the Geekobot team from manufacturer datasheets. Always check the datasheet for the exact part and variant you buy.

