TCRT5000 IR Sensor: Line Following Robots and Object Detection

TCRT5000 IR Sensor: Line Following Robots and Object Detection - Quality RC Parts

The TCRT5000 IR sensor is the part that lets a robot see the line it is supposed to follow. It shines infrared light at the floor and reads how much bounces back. A white surface reflects a lot, a black line reflects almost none, and the robot steers by the difference. The same trick detects objects, finds table edges, and counts things passing by. This guide covers how the TCRT5000 IR sensor works, how to build a line following robot with it, and how to use it for object detection.

TCRT5000 mini IR reflective sensor module, 3-pin, 10-pack

How a TCRT5000 IR sensor works

The TCRT5000 is a reflective optical sensor. One side is an infrared LED that shines light down at a surface. The other side is a phototransistor that reads the reflected light. A light surface sends most of the infrared back, so the phototransistor sees a strong signal. A dark surface absorbs it, so the signal drops. The module gives you both outputs: a digital output that flips high or low at a threshold you set with the onboard adjustment, and an analog output that reports the actual reflected level. It has three pins, VCC, ground, and OUT, runs on 3.3V or 5V, and works best 2 to 15mm from the surface. The TCRT5000 10-pack costs $9.99, which is a dollar per sensor.

Building a line following robot

A line follower is the classic TCRT5000 project. Mount two or three sensors under the front of the robot, 2 to 15mm above the floor, pointing down at a black line on a white surface. When the robot is centered on the line, the middle sensor sees black and the side sensors see white. When it drifts left, the left sensor sees black, and the code steers right to correct. When it drifts right, the opposite happens. Three sensors give you center, left, and right, and five sensors give you finer steering. The 10-pack covers a 5 sensor array with spares left over, or two robots with a 3 sensor array each. Use the digital output for simple line following and the analog output when you want to read shades of gray and steer smoothly instead of in steps.

Object detection and edge detection

The same sensor detects objects. Point it forward instead of down and an object in front reflects the infrared back, which trips the digital output. That is how a robot stops before it hits a wall or counts items passing on a conveyor. Point it down at a table and it becomes an edge detector: the table reflects, the drop past the edge does not, and the robot stops before it drives off. The adjustable range of 2 to 15mm sets how close an object has to be before it counts, so you can tune it for a slow robot that needs early warning or a fast one that only cares about what is right in front of it.

TCRT5000 IR reflective sensor module, close view

Tips that make the TCRT5000 work reliably

Sunlight is the enemy of an IR sensor, because sunlight is full of infrared. Shade the sensor from direct sun or run the robot indoors for reliable readings. Keep the sensing distance inside 2 to 15mm: too far and the signal is too weak, too close and the reading saturates. Keep the lens clean, because dust blocks infrared just like it blocks visible light. Calibrate the threshold on the actual floor you will run on, because a gray floor and a white floor give different readings. Use the analog output during testing to see the real signal levels, then set the digital threshold halfway between the line reading and the floor reading. Test on the real track before you trust the robot to run it alone.

What to pair it with

Pair the TCRT5000 with a small microcontroller and a robot chassis. An Arduino Nano runs the line following code with the Arduino IDE, and an RP2040-Zero runs it in MicroPython or C. Both have enough pins for a sensor array plus motor drivers. The 10-pack at $9.99 means the sensors are the cheapest part of the build, so spend the effort on the code and the chassis and let the sensors do the seeing.

Ships from our secure NY warehouse in the USA

Quality RC Parts is a USA shop, and every order ships from our secure NY warehouse. Orders leave in 1 to 2 business days with tracking sent by email, and shipping is free on orders over $100. No overseas wait, no customs. We are a working repair shop, and we stand behind every part we sell.