Contact Sales & After-Sales Service

Contact & Quotation

  • Inquire: Call 0086-755-23203480, or reach out via the form below/your sales contact to discuss our design, manufacturing, and assembly capabilities.
  • Quote: Email your PCB files to Sales@pcbsync.com (Preferred for large files) or submit online. We will contact you promptly. Please ensure your email is correct.
Drag & Drop Files, Choose Files to Upload You can upload up to 3 files.

Notes:
For PCB fabrication, we require PCB design file in Gerber RS-274X format (most preferred), *.PCB/DDB (Protel, inform your program version) format or *.BRD (Eagle) format. For PCB assembly, we require PCB design file in above mentioned format, drilling file and BOM. Click to download BOM template To avoid file missing, please include all files into one folder and compress it into .zip or .rar format.

TCRT5000 Arduino: Reflective Optical Sensor Tutorial

Meta:TCRT5000 Arduino guide: IR reflective sensor for line tracking robots. Pinout, circuit design, calibration tips, and dual-sensor line following code included.

The TCRT5000 Arduino pairing is one of the most reliable and cost-effective solutions for line following robots and proximity detection projects. After building dozens of line followers over the years, I keep coming back to this sensor because it just works. The Vishay TCRT5000 packs an infrared emitter and phototransistor into a compact package that costs less than a dollar, yet delivers consistent performance that rivals sensors costing five times as much.

How the TCRT5000 Reflective Sensor Works

The TCRT5000 is elegantly simple in concept. Inside the small plastic housing sit two components facing the same direction: an infrared LED that emits 950nm light, and a phototransistor that detects reflected infrared radiation. When you power the LED, it continuously sends out an invisible beam. If an object or surface sits within detection range, some of that infrared light bounces back to the phototransistor.

The phototransistor’s conductivity changes based on how much IR light it receives. More reflected light means higher conductivity and lower output voltage. Less reflected light (like from a black surface that absorbs IR) means lower conductivity and higher output voltage. This voltage variation is what your Arduino reads to determine whether an object is present and roughly how reflective the surface is.

One detail worth noting: the TCRT5000 includes a daylight blocking filter on the phototransistor side. That black coating you see isn’t just for aesthetics. It reduces interference from visible light sources, though ambient IR from sunlight or incandescent bulbs can still affect readings.

TCRT5000 Technical Specifications

Here’s what the Vishay datasheet tells us about this sensor:

ParameterSpecification
Operating Voltage5V (typical)
IR LED Forward Voltage1.2V to 1.6V
IR LED Forward Current60mA (max)
IR LED Wavelength950nm
Collector-Emitter Voltage70V (max)
Collector Current100mA (max)
Optimal Sensing Distance2.5mm
Effective Range0.2mm to 15mm
Operating Temperature-25°C to +85°C
Package Dimensions10.2 x 5.8 x 7mm

The “sweet spot” at 2.5mm is where you’ll get maximum signal-to-noise ratio. Go closer and the emitter and detector cones don’t overlap properly. Go further and signal strength drops rapidly.

TCRT5000 Raw Sensor Pinout

The bare TCRT5000 sensor has four pins. Understanding these is critical if you’re building your own interface circuit rather than using a pre-built module:

PinNameFunction
1Anode (A)IR LED positive terminal
2Cathode (C)IR LED negative terminal
3Collector (C)Phototransistor collector
4Emitter (E)Phototransistor emitter

The pins are arranged with the IR LED on one side and the phototransistor on the other. When viewing the sensor from the front (sensing side facing you), pins 1 and 2 are typically on the left, pins 3 and 4 on the right.

TCRT5000 Module Types and Pinouts

Most hobbyists use pre-built TCRT5000 modules that include the necessary resistors and often an LM393 comparator for digital output. These modules typically have three or four pins:

3-Pin Module (Digital Only)

PinFunction
VCCPower supply (3.3V to 5V)
GNDGround
OUTDigital output (HIGH/LOW)

4-Pin Module (Analog + Digital)

PinFunction
VCCPower supply (3.3V to 5V)
GNDGround
DODigital output
AOAnalog output (0-5V)

The 4-pin modules are more versatile. The analog output gives you a continuous voltage proportional to the reflected light intensity, while the digital output provides a simple HIGH/LOW based on the potentiometer threshold setting.

Building a Basic TCRT5000 Circuit

If you’re using the raw TCRT5000 sensor without a module, you’ll need to add resistors. Here’s a proven circuit:

For the IR LED (emitter): Connect a 220Ω to 330Ω resistor between the Arduino’s 5V pin and the LED anode. Connect the cathode to GND. This limits current to approximately 15-20mA, which provides good IR output without stressing the LED.

For the phototransistor (detector): Connect a 10kΩ pull-up resistor between 5V and the collector. Connect the emitter directly to GND. Take your output signal from the collector. This configuration outputs HIGH when no reflection is detected and LOW when a reflective surface is present.

ComponentConnection
IR LED Anode220Ω resistor → 5V
IR LED CathodeGND
Phototransistor Collector10kΩ resistor → 5V, also to Arduino analog pin
Phototransistor EmitterGND

Increasing the pull-up resistor value (up to about 47kΩ) increases sensitivity but may slow response time. Decreasing it reduces sensitivity but improves speed.

Wiring TCRT5000 Module to Arduino

Using a pre-built module simplifies wiring considerably:

Module PinArduino UnoArduino MegaArduino Nano
VCC5V5V5V
GNDGNDGNDGND
DOD2D2D2
AOA0A0A0

The analog pin choice (A0) is arbitrary. Use any available analog input on your Arduino. Similarly, the digital pin can be any GPIO capable of digital input.

Basic TCRT5000 Arduino Code

This sketch reads both analog and digital outputs and displays results on the Serial Monitor:

const int digitalPin = 2;

const int analogPin = A0;

void setup() {

  Serial.begin(9600);

  pinMode(digitalPin, INPUT);

}

void loop() {

  int analogValue = analogRead(analogPin);

  int digitalValue = digitalRead(digitalPin);

  Serial.print(“Analog: “);

  Serial.print(analogValue);

  Serial.print(”  Digital: “);

  Serial.println(digitalValue);

  delay(100);

}

Move a white piece of paper toward and away from the sensor. You’ll see the analog value decrease as the paper gets closer (more light reflected, lower resistance, lower voltage). The digital output will flip from HIGH to LOW when the reflection crosses the threshold set by the onboard potentiometer.

Line Following Robot Application

The most common use for the TCRT5000 Arduino combination is building line following robots. The sensor detects the contrast between a black line and a white background (or vice versa).

Single Sensor Line Detection

One sensor can tell you if you’re on or off the line, but not which direction to correct. Still, it’s useful for simple applications:

const int sensorPin = 2;

const int ledPin = 13;

void setup() {

  pinMode(sensorPin, INPUT);

  pinMode(ledPin, OUTPUT);

}

void loop() {

  if (digitalRead(sensorPin) == HIGH) {

    // Black line detected (less reflection)

    digitalWrite(ledPin, HIGH);

  } else {

    // White surface detected (more reflection)

    digitalWrite(ledPin, LOW);

  }

}

Dual Sensor Line Following

Two sensors positioned on either side of the line provide directional information:

const int leftSensor = 2;

const int rightSensor = 3;

const int leftMotor = 5;

const int rightMotor = 6;

void setup() {

  pinMode(leftSensor, INPUT);

  pinMode(rightSensor, INPUT);

  pinMode(leftMotor, OUTPUT);

  pinMode(rightMotor, OUTPUT);

}

void loop() {

  int left = digitalRead(leftSensor);

  int right = digitalRead(rightSensor);

  if (left == LOW && right == LOW) {

    // Both on white – go straight

    digitalWrite(leftMotor, HIGH);

    digitalWrite(rightMotor, HIGH);

  }

  else if (left == HIGH && right == LOW) {

    // Left on black – turn left

    digitalWrite(leftMotor, LOW);

    digitalWrite(rightMotor, HIGH);

  }

  else if (left == LOW && right == HIGH) {

    // Right on black – turn right

    digitalWrite(leftMotor, HIGH);

    digitalWrite(rightMotor, LOW);

  }

  else {

    // Both on black – stop or reverse

    digitalWrite(leftMotor, LOW);

    digitalWrite(rightMotor, LOW);

  }

}

For smooth line following, use the analog outputs and implement PID control rather than simple on/off logic.

Adjusting Sensitivity with the Potentiometer

Most TCRT5000 modules include a small blue potentiometer (trimmer) that adjusts the detection threshold. This controls when the digital output switches between HIGH and LOW.

Turn the potentiometer clockwise to increase sensitivity (detect weaker reflections). Turn counterclockwise to decrease sensitivity (require stronger reflections to trigger).

To calibrate properly:

  1. Position the sensor at your intended operating distance
  2. Place a black surface underneath
  3. Turn the potentiometer until the digital output reads HIGH
  4. Replace with a white surface
  5. Verify the output switches to LOW
  6. Fine-tune until you get reliable switching between both surfaces

Reducing Ambient Light Interference

The TCRT5000’s daylight filter helps, but bright ambient IR can still cause false readings. Here are practical solutions:

Physical shielding: Add a small tube or shroud around the sensor to block side light. Black heat shrink tubing works well.

Software filtering: Sample multiple readings and average them. Discard outliers:

int getFilteredReading(int pin, int samples) {

  long sum = 0;

  for (int i = 0; i < samples; i++) {

    sum += analogRead(pin);

    delay(2);

  }

  return sum / samples;

}

Modulated detection: Briefly turn off the IR LED, take a baseline reading, turn it back on, and compare. The difference represents actual reflection rather than ambient IR.

Common TCRT5000 Problems and Solutions

No Response from Sensor

Check your resistor values. If the IR LED resistor is too high, insufficient current flows and the LED won’t emit enough light. If the pull-up resistor on the phototransistor is missing, the output floats randomly.

Digital Output Stuck HIGH or LOW

Adjust the potentiometer. If it’s turned too far in either direction, the threshold may be outside the actual sensor range. Also verify your supply voltage matches what the module expects.

Erratic Readings Outdoors

Sunlight contains strong infrared components that overwhelm the sensor. Add physical shielding or switch to a modulated detection scheme. Alternatively, design your project for indoor use only.

Detection Range Too Short

Ensure the sensing surface is parallel to the sensor face. Angled surfaces reflect IR away from the phototransistor. Also check that both the IR LED and phototransistor windows are clean.

Useful Resources and Downloads

ResourceDescriptionLink
TCRT5000 DatasheetOfficial Vishay specificationsvishay.com
Arduino IDEDevelopment environmentarduino.cc
LM393 DatasheetComparator used in modulesti.com
Line Following TutorialAdvanced PID control guideArduino Project Hub

Frequently Asked Questions

What is the maximum detection distance for the TCRT5000?

The effective detection range is approximately 0.2mm to 15mm, with optimal performance around 2.5mm. Beyond 15mm, the signal-to-noise ratio degrades significantly. If you need longer range detection, consider ultrasonic sensors like the HC-SR04 or laser-based ToF sensors like the VL53L0X.

Can I use multiple TCRT5000 sensors with one Arduino?

Yes. Each sensor needs its own analog input pin (for analog output) or digital input pin (for digital output). Arduino Uno has 6 analog inputs and 14 digital pins, so you can easily connect 5-6 sensors for a multi-sensor line follower. Just ensure your power supply can handle the combined current draw.

Why does my TCRT5000 work indoors but not outdoors?

Sunlight contains significant infrared radiation that interferes with the sensor’s phototransistor. The daylight filter reduces visible light interference but can’t block all ambient IR. Use physical shielding, software filtering, or modulated detection to improve outdoor performance.

What’s the difference between TCRT5000 and TCRT5000L?

The TCRT5000L is simply the long-lead version of the same sensor. Electrically they’re identical. The L variant has longer pins (11mm vs 6mm) for easier mounting in certain applications. Choose whichever fits your mechanical requirements.

Can the TCRT5000 detect colors other than black and white?

The sensor responds to surface reflectivity in the infrared spectrum, not visible color. However, many visible colors have different IR reflectance properties. You can distinguish some colors on a grayscale, but it’s not reliable enough for true color detection. For actual color sensing, use a dedicated RGB sensor like the TCS3200.

Wrapping Up

The TCRT5000 Arduino combination remains a workhorse for proximity detection and line following applications. The sensor’s low cost, simple interface, and reliable performance make it an excellent choice for educational robotics and hobby projects. Whether you’re building your first line follower or adding obstacle detection to an existing robot, the TCRT5000 delivers solid results without breaking your budget.

For best results, use a pre-built module with the LM393 comparator, position the sensor at approximately 2.5mm from your target surface, and calibrate the sensitivity potentiometer for your specific environment. With proper setup, you’ll have a detection system that just works.

Leave a Reply

Your email address will not be published. Required fields are marked *

Contact Sales & After-Sales Service

Contact & Quotation

  • Inquire: Call 0086-755-23203480, or reach out via the form below/your sales contact to discuss our design, manufacturing, and assembly capabilities.

  • Quote: Email your PCB files to Sales@pcbsync.com (Preferred for large files) or submit online. We will contact you promptly. Please ensure your email is correct.

Drag & Drop Files, Choose Files to Upload You can upload up to 3 files.

Notes:
For PCB fabrication, we require PCB design file in Gerber RS-274X format (most preferred), *.PCB/DDB (Protel, inform your program version) format or *.BRD (Eagle) format. For PCB assembly, we require PCB design file in above mentioned format, drilling file and BOM. Click to download BOM template To avoid file missing, please include all files into one folder and compress it into .zip or .rar format.