Interfacing TCRT5000 IR Sensor with Arduino


Today we will learn how to Interfacing TCRT5000 IR Sensor with Arduino, Infrared (IR) sensors are widely used in electronics and robotics for detecting objects, obstacles, or line tracking. The TCRT5000 IR Sensor is a popular choice due to its compact design and reliable performance. In this comprehensive guide, we will explore the working principle and features of the TCRT5000 sensor. Additionally, we will learn how to interface it with an Arduino UNO to create a simple object detection system. By the end of this tutorial, you will have the knowledge and skills to integrate the TCRT5000 IR Sensor into your projects, adding versatile infrared detection capabilities. So, let’s dive into the world of infrared sensing with Arduino and uncover the potential of the TCRT5000 IR Sensor!

Hardware Required

You will require the following Hardware Components for Interfacing TCRT5000 IR Sensor with Arduino.

Components#Buy From Amazon
Arduino UNO1Buy Now
TCRT5000 IR Sensor1Buy Now
9v DC Adapter (Optional)1Buy Now
Jumper Wires3Buy Now
Breadboard1Buy Now

What is TCRT5000 IR Sensor?

The TCRT5000 IR Sensor is an infrared reflective sensor that consists of an infrared LED and a phototransistor. When the IR LED emits infrared light, it strikes the surface in front of the sensor. If the surface is reflective, such as a white object or a surface with a white marker, the infrared light is reflected back towards the phototransistor. The phototransistor then detects this reflected light, and its resistance changes accordingly. This change in resistance is used to determine whether an object is present or not. The TCRT5000 sensor is ideal for detecting objects in close proximity and can be used for various applications, such as obstacle avoidance and line following in robotics.



Pin Configuration

Pin NamePin Type
VCCPower Supply – 5V
GNDGround Pin
OUTDigital output signal


  1. Detection Range: The TCRT5000 sensor has a short-range detection capability suitable for close-proximity sensing.
  2. Sensing Method: It employs infrared reflection sensing for object detection.
  3. Operating Voltage: The sensor operates within the voltage range compatible with Arduino UNO.
  4. Compact Size: The small form factor of the TCRT5000 sensor allows for easy integration into projects.


  1. Non-Contact Sensing: The TCRT5000 sensor provides non-contact object detection, making it suitable for applications requiring no physical contact with the objects being detected.
  2. Fast Response Time: The sensor exhibits a fast response time, enabling real-time object detection in dynamic environments.
  3. Low Power Consumption: The TCRT5000 sensor operates with low power consumption, making it suitable for battery-powered applications.

Circuit Diagram

We fix the values of pins 5 and 6 in the code in a method that the connection wires are no longer required. So you can put the module directly on Arduino. like in this circuit


Circuit Connections


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


//For more Projects:

int GND = 5;
int VCC = 6;
int OUT = 7;

void setup() {

  // initialize serial communication at 9600 bits per second:
  pinMode(GND, OUTPUT);
  pinMode(VCC, OUTPUT);
  pinMode(OUT, INPUT);

  digitalWrite(GND, LOW);
  digitalWrite(VCC, HIGH);

void loop() {

  int sensorValue = digitalRead(OUT);
  if (sensorValue == 0){
      Serial.println("black color");
  if (sensorValue == 1){
      Serial.println("other colors");

Output Result

In this program, we set pin 5 to Low and pin 6 to High to serve as ground and VCC connections. Pin 7 is set as a digital input, and we continuously check its output. If the output is HIGH, it means there is no black object in front of the sensor. However, if we place a black object or nothing in front of it, the output becomes LOW.

We test different colors, and if the color is not black, the output will be HIGH, and the message “other colors” is displayed.



  1. Obstacle Avoidance: The sensor can be used in robots and vehicles to detect obstacles in their path and avoid collisions.
  2. Line Following: In line following robots, the TCRT5000 sensor can track lines on the ground, allowing robots to follow specific paths.
  3. Proximity Sensing: The sensor can be employed in proximity sensing applications, such as detecting the presence of hands or objects near a surface.
  4. Surface Reflectivity Testing: It can be used to measure the reflectivity of surfaces, aiding in quality control and testing processes.


You have now familiarized yourself with the TCRT5000 IR Sensor and its capabilities in infrared detection projects. By interfacing the sensor with Arduino UNO, you can create object detection and line following systems for various robotic applications. The TCRT5000’s fast response time and compact design make it an excellent choice for close-proximity sensing. Armed with this knowledge, you can now explore the world of infrared detection and implement the TCRT5000 IR Sensor in your projects. So, unleash your creativity and delve into the endless possibilities of infrared sensing with the TCRT5000 IR Sensor and Arduino.

Leave a Comment