Introduction to Arduino TCRT5000 (IR Sensor)

I ended up with about 300 of these little TCRT5000 Infra Red Sensors after an eBay purchase and wasn’t quite sure what I should do with them.  And then I was having a discussion with a friend (Darcy) who was talking about a way to get people a bit more involved with the Arduino community in Ottawa.  After a few beers, the Ottawa Arduino Challenge was born.  The idea was simple.  Give participants a small surprise sensor or component which they must use in their project submission within 4 weeks.  In order to win, it would be vote by public so you really needed to be able to share your project with the world.

 Arduino tcrt5000

What is a TCRT5000 IR Sensor?

Well, I can tell you what it isn’t! And despite it’s looks, it unfortunately is not a Star Wars Walker!!!  However, it is an IR Emitter and an IR PhotoTransistor packaged together.  The Ardiuno TCRT5000 is designed to sense the distance to an object using Infra Red light waves.  It can also identify the difference between white and black based on the contrast of an object and it’s reflective properties.

Arduino TCRT5000 Datasheet



How To Use the Arduino TCRT5000

Wiring up the TCRT5000 to an Arduino is relatively straight forward.  Simply connect the Anode (A) of the IR emitter to a 100 ohm resistor which has 5V applied, then connect the Cathode (C) of the IR Emitter to Ground (GND) on the arduino.  Next you need to connect the Emitter (E) of the Photo Transistor to ground, then apply 5V to a 10,000 ohm resistor which connects to the Collector (C).  Finally to measure the voltage drop produced by the transistor all we need to do is connect an analog pin from the Arduino to the Collector (C) of the Transistor.



Sample Arduino TCRT5000 Code

You actually don’t even have to write any code to start using the Arduino TCRT5000 sensor, all you need to do is launch the AnalogReadSerial example and Upload it to your Arduino.  Then simply open the serial monitor window to see what is going on.



  1. Hi! Great post! Could you tell me how to increase measure distance?

  2. Hello,

    Do you know how this TCRT5000 would compare with a H21B1 Photodarlington Optical Interrupter Switch (cut in the middle with the two parts glued side by side) ?


  3. @IDUL The 100 ohm resistor lets the LED run at 50 mA which is 10 mA under the maximum, so it running “bright” but within safe limits. Look up V=IR. The 10k ohm resistor is chosen to be in a useful range for the transistor to be in active mode. Look up NPN transistor and phototransistor. From the datasheet for this device, a 0.5 mA collector current (“switch closed”) corresponds to 5V collector-emitter voltage when LED is running at 50 mA and a reflecting surface is right up close. Vcc (5V) with a 10k resistor yields a 0.5 mA max current through the phototransistor. The intensity of reflected light will then produce values of between 5V (no light) and 0.2V (full light) for the voltage between collector and emitter (and your Arduino analog pin is connected to measure this). It will yield digital values of to 1023. My understanding is that you can’t get true zero Vce due to current coming from the base (in this case generated by the photo thingy) but I can’t elaborate further as it’s beyond the scope of my knowledge.

  4. The previous post needs an edit. If the moderator (hello dave?) can simply delete it, that would be appreciated.

  5. @Dave: I think the ultrasound sensor might be too slow.
    @Joseph: the TCRT5000 can be fooled by sunlight, you have to account for this

  6. What would change in the code for the TCRT5000 to detect lines and avoid them

  7. Can i use this code and connection , and how? , so when the TRCT5000 detects something a little engine starts working ?

Leave a Reply to Ganesh Cancel reply

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