How to Use Line Detector with Arduino and TCRT5000L Sensor


In this project we learn How to Use Line Detector with Arduino and TCRT5000L Sensor, The TCRT5000L is no ordinary sensor; it’s a reflective optical sensor that taps into the world of color difference detection by harnessing the power of reflected infrared light. In this guide, we’ll explore the basics, functionalities, and applications of the TCRT5000L sensor, shedding light on how it can be seamlessly integrated into Arduino projects.

Hardware Required

You will require the following Hardware Components for interfacing TCRT5000L Sensor with Arduino.

Components#Buy From Amazon
Arduino UNO1Buy Link
TCRT5000L Sensor1Buy Link
9v DC Adapter (Optional)1Buy Link
Jumper Wires3Buy Link
Breadboard1Buy Link

What is the Module?

The TCRT5000L comprises an LED emitter and a phototransistor receiver, creating a simple yet effective mechanism for detecting objects. By emitting infrared light and analyzing its reflection, the sensor discerns color variations, making it adept at distinguishing dark areas on an object.



Pin Configuration

Pin NamePin Type
VCCPositive Supply Pin +5V
GNDGround Pin
A0Analog Pin
D0Digital Pin


  1. Measurement Range: 0.2 to 15mm.
  2. Optimal Distance: 2.5mm.
  3. Output: Digital signal facilitated by the LM393 comparator on the standard measurement board.
  4. Threshold Regulation: Achieved through a potentiometer on the board.
  5. Precision: While not providing distance estimates, it excels at object detection.

Circuit Diagram

The following circuit shows you the connection of How to Use Line Detector with Arduino and TCRT5000L Sensor Please make the connection carefully


Installing Arduino IDE Software

First, you will require to Download the updated version of Arduino IDE Software and Install it on your PC or laptop. if you Learn How to install the Arduino step-by-step guide then click on how to install Arduino Button given Blow


To detect when the TCRT5000L passes over a dark area we simply read the state of the digital input, as we saw in the entry Digital inputs on Arduino.

When the sensor is triggered we will take the appropriate actions, such as stopping or changing the direction of a robot.

//For more Projects:

const int sensorPin = 9;

void setup() {
  Serial.begin(9600); //start serial port
  pinMode(sensorPin, INPUT); //define pin as input
void loop(){
  int value = 0;
  value = digitalRead(sensorPin ); //digital pin reading
  if (value == LOW) {
      Serial.println("TCRT5000L activated"); //dark zone


  1. Line Following Robots: TCRT5000L sensors are integral in creating robots that follow lines by detecting variations in surface color.
  2. Object Detection: Use TCRT5000L sensors to trigger actions or alerts when an object is detected within its measurement range.
  3. Paper Detection in Printers: TCRT5000L sensors are employed to detect when paper is running out, ensuring uninterrupted printing processes.
  4. Automated Sorting Systems: Integrate TCRT5000L sensors into sorting systems for efficient categorization.


The TCRT5000L sensor, with its infrared wizardry, brings a touch of magic to reflective optical sensing. From robots tracing lines to printers managing paper levels, this sensor’s simplicity belies its versatility. As you embark on your Arduino journey, let the TCRT5000L be your guide into the fascinating realm of color difference detection and object sensing. Explore, experiment, and illuminate your projects with the TCRT5000L’s reflective brilliance.

Leave a Comment