Description
TCRT5000 Infrared Obstacle Detection Sensor Module
The TCRT5000 is a reflective infrared sensor module for detecting nearby objects, surface changes and lines. Its infrared emitter and phototransistor work together, and the board provides both digital and analog outputs.
Specifications
- Operating voltage: 3.3–5 V
- Outputs: digital (D0) and analog (A0)
- Operating temperature: −25 °C to +85 °C
- Board dimensions: 32 × 14 mm
- Detection distance: the source listing gives both 1–8 mm and 1–25 mm
- Current: the source listing gives 20 mA in one section and 60 mA (diode) / 100 mA (transistor) in another. Check the module’s datasheet for the exact figures.
How it works
The infrared LED emits light toward the target. A nearby object or line reflects some of that light back to the phototransistor. The reflected-light level changes the sensor output, allowing the module to detect objects and distinguish surface variations. The onboard adjustment can be used to set the digital switching threshold.
Pinout
- VCC: 3.3 V or 5 V supply
- GND: ground
- D0: digital output
- A0: analog output
Typical applications
- Line-following and maze-solving robots
- Presence and obstacle detection
- Surface/reflection sensing in DIY projects
- Position and object detection in automation projects
Using the digital output with Arduino Uno
Parts
- 1 × TCRT5000 sensor module
- 1 × Arduino Uno
- Jumper wires and a breadboard
Example: digital output (D0)
int sensorPin = 2; // Broche connectée à D0 du capteur
int ledPin = 13; // Broche connectée à la LED intégrée
void setup() {
pinMode(sensorPin, INPUT);
pinMode(ledPin, OUTPUT);
Serial.begin(9600);
}
void loop() {
int sensorValue = digitalRead(sensorPin);
if (sensorValue == LOW) {
digitalWrite(ledPin, HIGH);
Serial.println("Obstacle détecté");
} else {
digitalWrite(ledPin, LOW);
Serial.println("Pas d'obstacle");
}
delay(1000);
}
What the digital example does
- Configures Arduino pin 2 as the sensor input and pin 13 as the built-in LED output.
- Reads D0. When the module reports LOW, the LED turns on and the serial monitor reports that an obstacle was detected; otherwise the LED turns off.
- Repeats the reading once per second.
Using the analog output with Arduino Uno
Additional parts
- 1 × TCRT5000 sensor module and 1 × Arduino Uno
- 1 × I2C 1602 LCD
- 1 × LED and 1 × 220 Ω resistor
- Jumper wires and a breadboard
Example: analog output (A0)
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
int analogPin = A0; // Broche connectée à A0 du capteur
int ledPin = 13; // Broche connectée à une LED externe
LiquidCrystal_I2C lcd(0x27, 16, 2);
void setup() {
lcd.begin();
lcd.backlight();
pinMode(analogPin, INPUT);
pinMode(ledPin, OUTPUT);
Serial.begin(9600);
}
void loop() {
int sensorValue = analogRead(analogPin);
lcd.setCursor(0, 0);
lcd.print("Valeur: ");
lcd.print(sensorValue);
lcd.setCursor(0, 1);
if (sensorValue < 512) { // Si la valeur est inférieure à la moitié de la plage maximale (1023/2)
digitalWrite(ledPin, HIGH);
lcd.print("Obstacle proche");
Serial.println("Obstacle détecté");
} else {
digitalWrite(ledPin, LOW);
lcd.print("Pas d'obstacle ");
Serial.println("Pas d'obstacle");
}
delay(1000);
}
What the analog example does
- Includes the
WireandLiquidCrystal_I2Clibraries and initializes a 16 × 2 LCD at I2C address0x27. - Reads the analog signal on
A0and displays the reading and detection status on the LCD. It also reports the status over the serial connection. - In this example, a reading below 512 is treated as a nearby obstacle: the LED is switched on and the display reports “Obstacle proche”. At 512 or above, the LED is switched off.
- Waits one second between readings.
Library setup
- Open the Arduino IDE and go to Sketch → Include Library → Manage Libraries.
- Search for
LiquidCrystal_I2Cand install the library by Frank de Brabander.
Keywords: TCRT5000, infrared sensor, IR sensor, obstacle detection, line follower, reflective sensor, proximity sensor.










