____       _          ____                        
|  _ \ ___ | |__   ___/ ___| _   _ _ __ ___   ___  
| |_) / _ \| '_ \ / _ \___ \| | | | '_ ` _ \ / _ \ 
|  _ < (_) | |_) | (_) |__) | |_| | | | | | | (_) |
|_| \_\___/|_.__/ \___/____/ \__,_|_| |_| |_|\___/ 
                                                   
  ____            _    _                 _    
 / ___|___   ___ | | _| |__   ___   ___ | | __
| |   / _ \ / _ \| |/ / '_ \ / _ \ / _ \| |/ /
| |__| (_) | (_) |   <| |_) | (_) | (_) |   < 
 \____\___/ \___/|_|\_\_.__/ \___/ \___/|_|\_\

Introducing the TCRT5000 reflective infrared sensor

The TCRT5000 is an infrared reflective sensor. It can be used as a proximity sensor (detecting when an object is close), a crude colour sensor (detecting a difference between dark and light colours), or many other applications. In RoboSumo, the main use of this sensor is to detect the colour of the ground underneath a robot, or the edge of a surface the robot is driving on.

The TCRT5000 is a 4-pin device. To find out which pin is which, download the datasheet:

Instructions to build a convenient TCRT5000 sensor module either on terminal block or printed circuit board (PCB) are available here:

This is the TCRT5000 sensor:

insert alt text here

insert alt text here

This is a typical circuit for reading the output voltage of the TCRT5000 with an Arduino. Analog input pin A3 is used to measure the sensor voltage.

insert alt text here

insert alt text here

insert alt text here

//
// TRCT5000 sensor example
// Written by Ted Burke - last updated 4 Oct 2023
//

void setup()
{
  pinMode(4, OUTPUT);

  Serial.begin(9600); // open a serial link to PC at 9600 bits/s
}

void loop()
{
  int sensorVoltage; // phototransistor voltage

  sensorVoltage = analogRead(3); // read voltage from pin A3 as a number between 0 and 1023

  Serial.println(sensorVoltage);

  if (sensorVoltage > 512)
  {
    digitalWrite(4, HIGH); // LED on    
  }
  else
  {
    digitalWrite(4, LOW); // LED off
  }
}

insert alt text here