TCRT5000 Explained: How Line-Following Sensors Work, and How to Wire One to an Arduino Uno
Share
The TCRT5000 is a reflective optical sensor that pairs an infrared LED emitter with an IR phototransistor receiver, mounted side by side on the same face of the module. It works by measuring reflected infrared light rather than light passing through: a light-colored surface, like a white line or unpainted floor, bounces more IR back to the receiver, while a dark surface, like black tape, absorbs most of it. The breakout module exposes four pins — VCC, GND, a digital output (DO) gated through an onboard LM393 comparator with an adjustable threshold potentiometer, and an analog output (AO) carrying the raw phototransistor reading — runs on 3.3–5V, and only works reliably within about 2–15mm of the surface it's reading.
How does the TCRT5000 detect a line?
The emitter and receiver face the same direction, so the only light the phototransistor sees is whatever bounces straight back off whatever is directly underneath the module. Over a white or light-colored surface, a good fraction of the emitted infrared reflects back and the receiver's output rises. Over a black line or dark tape, the surface absorbs most of that infrared instead of reflecting it, so the receiver sees much less light. The onboard LM393 comparator turns that difference into a clean digital transition on DO once the reading crosses a threshold you set with the potentiometer — that's the entire mechanism a line-following robot relies on to tell "line" from "no line."
What's the difference between the DO and AO outputs?
DO is a simple threshold: once reflected light crosses the level set by the onboard potentiometer, the pin flips between HIGH and LOW — exactly which state means "line detected" depends on how the invert-logic is set on your particular board. It's enough for basic two-state line following: read each sensor with digitalRead() and turn based on which one sees the line. AO instead outputs the phototransistor's raw, continuous reflectance value, which is what you want if you're tuning the exact threshold yourself or running an edge-detection algorithm like PID line following, where knowing how close to the line edge you are matters more than a binary flag.
How do you wire the TCRT5000 to an Arduino Uno?
| Arduino Uno | TCRT5000 | Signal |
|---|---|---|
| 5V | VCC | power |
| GND | GND | ground |
| D2 (any digital pin) | DO | digital threshold output |
| A0 (any analog pin) | AO | analog reflectance output |
You don't need both outputs wired at once — most builds pick one. A basic two-sensor line follower typically only uses DO on each sensor; a build tuning its own threshold in software reads AO instead. Multi-sensor arrays (three or more TCRT5000 units side by side) just repeat this pattern across additional digital or analog pins, one per sensor.
How close does the TCRT5000 need to be to the surface?
Its effective sensing range is short, roughly 2–15mm from the surface, because it depends on IR bouncing straight back rather than travelling any real distance. That's why line-following robots mount it right above the track, close to the floor, rather than up on the chassis somewhere convenient. Too far and the reflected light is too weak for the comparator to distinguish light from dark; too close and the emitter and receiver's fields of view don't overlap correctly either.
Watch it built live: a real Arduino Uno + TCRT5000 project
Rather than describe a generic build, we typed one real sentence into Compoden's AI build assistant on the storefront and let it do the part-picking, pricing, and explaining — unscripted, screenshotted as it happened:
"I want to build a line-following robot project using a TCRT5000 and an Arduino Uno"

It picked seven in-stock parts — three TCRT5000 sensors, an Arduino Uno, an L298N motor driver, two DC gear motors, a 2WD chassis, a 9V battery snap, and jumper wire — and explained each in plain terms. On the sensors specifically, it wrote: "You will use three TCRT5000 IR Line Follower / Proximity Sensor Modules. Each sensor measures reflectance, which is how much light bounces back from a surface... By placing these sensors side-by-side, the robot can detect if it is on the line, or if it is drifting off to one side." It also flagged, unprompted, that the build's motors and driver together draw roughly 5.1A, more than the listed 9V snap connector alone is rated to comfortably supply — a real power-budget check, not a generic disclaimer.
Watch the firmware get generated
We then asked Compoden's build companion, Soldr, to write the actual Arduino sketch for the same project — targeting the Uno specifically, reading the sensors and printing to the serial monitor:

The generated sketch wires the left and right TCRT5000 sensors to analog pins A0 and A1, reading continuous reflectance values with analogRead() rather than a simple digital threshold, and drives the L298N motor driver on four digital pins for forward/left/right/stop logic, with serial output set to 115200 baud. Soldr also flagged, before letting you flash it, that two of the pin assignments in the generated code didn't match the wiring diagram it had drawn for the same build — a useful catch, since a mismatch there is exactly the kind of thing that silently stops a robot from working even though the code compiles cleanly.
So what is the TCRT5000 actually good for?
Anything that needs to tell reflective from non-reflective at very short range: line-following robots, sumo-robot edge and boundary detection, counting items as they pass on a conveyor, and encoder-style wheel speed sensing using a reflective strip on a spinning wheel. It's a two-part build (LED plus phototransistor) with no microcontroller of its own, which keeps it cheap and simple, but also means the sensing logic — threshold, filtering, multi-sensor voting — is entirely up to your firmware.
Get everything in this build
The exact seven parts Soldr picked above, at today's live price and stock — each links straight to checkout, or add the whole tray in one click.
| Part | Qty | Price | |
|---|---|---|---|
| Arduino Uno R3 CH340G ATmega328P Board | 1 | ₹230 | Add to cart → |
| TCRT5000 IR Line Follower / Proximity Sensor Module | 3 | ₹30 each | Add to cart → |
| L298N Motor Driver Module | 1 | ₹180 | Add to cart → |
| 20RPM BO Motor Dual Side – L Shape | 2 | ₹91 each | Add to cart → |
| 2WD Robot Chassis Kit | 1 | ₹280 | Add to cart → |
| 9V Battery Snap Connector | 1 | ₹35 | Add to cart → |
| 23 AWG Multi-Strand Breadboard Wire | 1 | ₹10 | Add to cart → |
| Total | ₹1,007 | Add all 7 to cart → |
Prices and stock verified live at the time this was written; Compoden's storefront always reflects the current price at checkout.
Built and Backed by Compoden
Every part above ships from Compoden's own India stock, tested for compatibility before it's carded together — not sourced individually and hoped to work. Delivery in 3–7 days across India, with COD and UPI available at checkout. If a part in this build doesn't perform as described, Compoden's support team will help you troubleshoot or replace it.
FAQ
Is the TCRT5000 digital or analog?
Both. The module has a digital output (DO) that gives a simple HIGH/LOW threshold crossing via an onboard LM393 comparator, and a separate analog output (AO) that gives the phototransistor's raw, continuous reflectance reading. Which one you wire up depends on whether your firmware just needs a threshold or a tunable value.
Why does the TCRT5000 need to be so close to the surface?
It only detects light that bounces straight back to its receiver, and that reflected signal weakens fast with distance. The usable range is roughly 2–15mm, which is why it's mounted directly above the track on a line-following robot rather than higher up on the chassis.
Can the TCRT5000 tell the difference between white and black surfaces in bright ambient light?
Strong ambient IR, such as direct sunlight, can raise the receiver's baseline reading and make the threshold set on the DO comparator less reliable. Most indoor and typical classroom or workshop lighting doesn't cause problems, but outdoor daylight testing usually needs the threshold potentiometer re-tuned.
How many TCRT5000 sensors does a line-following robot need?
Two is the practical minimum for basic left/right correction. Three or more, spaced across the front of the chassis, let the firmware detect sharper turns and intersections more precisely, which is why a three-sensor array is a common starting configuration.