Introduction: TCRT5000 Infrared Reflective Sensor - How It Works and Example Circuit With Code

Hello, I recently used a bunch of TCRT5000's when designing and making my coin sorting machine. You can see that here:

To do this I had to learn about the TCRT5000 and after I understood it I thought I would create guide for anyone else who was looking to understand more about the sensor.

This is going to be that guide. I'll write out a written version in full below, but if you would prefer to watch me explain it in a video then please check out the video below:

Step 1: Video

Step 2: What Does It Look Like?

This is what the TCRT5000 looks like on its own. It consists of an infrared LED and a phototransistor (that is sensitive to light). This sensor has a coating on it to filter out light that is not within the infrared spectrum to help reduce the chance of environmental interference - this is what gives the input side of the TCRT5000 its black colour.

You’ll also often see it on a board alongside a LM393 and adjustable potentiometer. We'll go over this in a bit.

Step 3: What Could It Be Used For?

You can use the TCRT5000 to check the presence of a physical object such aa detecting a coin in a coin sorting device.

It can also be used to check the colour of something on a black to white scale. This is a principle a line following robot can utilise. The different shades change the level of reflected infrared light.

Step 4: How Does It Work?

The TCRT5000 itself works by transmitting infrared light from the LED and registering any reflected light on its phototransistor this alters the flow of current between its emitter and collector according to the level of light it receives.

This board that you’ll often find it on also includes additional features to increase its ease of use. It adds a Voltage comparator chip in the form of this LM393 and a potentiometer to adjust its sensitivity. It presents us with four pins. VCC, GND, D0 and A0.

We supply a working voltage between 3.3v and 5v through the VCC and Ground pins. We receive our sensor data though either of the two remaining pins.

The analogue pin A0 provides a continuous reading in the form of varying voltage, the higher the voltage the more infrared light is being received.

The digital pin on the other hand is either high (on) or low (off). When the board is powered and not enough infrared light is received the digital pin will be high, and when the trigger level set by the potentiometer is passed the digital pin is then set to low.

One major drawback of this sensor is it can be easily affected by environmental conditions. Any other source of infrared light such as sunlight or house lights are also detected by the sensor and can interfere with the readings.

This can be limited with clever code that can perform noise cancellation or by briefly turning the emitter off, taking a baseline reading of the environment, then turning emitter back on and checking for any change in received light levels.

Step 5: Mini Make: Example Project

This mini make will demonstrate both the analogue and digital pins. Assemble the circuit as shown and then upload the code provided in the link below to your Arduino Uno.

Open the serial monitor and watch what happens as you move a reflective object closer to the sensor. The serial monitor is printing out the reading from the analogue sensor. The onboard LEDs on both the Arduino board and sensor board are showing the state of the reading from the digital pin. When the threshold of reflectivity has not been met, the digital pin is high and our LEDs are on. As the object gets nearer and the threshold is passed the digital pin changes to low and the LED goes out.

Remember that you can adjust the sensitivity with the potentiometer.

Step 6: Thanks

If you would like to say thanks for this guide and design please confider buying me a coffee:

You can also support our channel and keep us creating these guides over on Patreon:

Please don't forget to subscribe here on Instructables or our Youtube channel to find out when we have our next DIY project ready.