Analogread from a TCRT5000 sensor

Posted by: Chao Category: Sensing and Actuating Comments: One Comment

Analogread from a TCRT5000 sensor

We have the TCRT 5000 sensors in stock, it’s a pretty cheap $0.35 for 2 pcs, and easy to use sensors, you can find the product here.

Now we found a detailed tutorial about how to set it up and use it from Bajdi blog, see the wiring and sketch below. Only a few external components are needed.

The TCRT 5000 sensor send PWM signal to indicate an LED.”When the sensor detects nothing the led lights up. When there is an object very close to the sensor the led dims. I can also read the analog reading of the serial monitor. This sensor is ideal to use for a line following robot. I originally thought about using it as an object detection sensor. But it is not suitable for this. It only detects object that are really close to the sensor.”

And use this sketch below

Analog reading of TCRT5000 sensor connected to Arduino Uno
TCRT5000 pins: (see datasheet )
C = Arduino analog pin A0 and to one end of 4K7 resistor, other end of resistor to 5V
A = 100 ohm resistor, other end of resistor to 5V

const int led = 11; // the number of the LED pin
int tcrt;

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

void loop(){
tcrt = analogRead(A0);
analogWrite(led, tcrt/4);

Share this post

Comment (1)

  • poulbran Reply

    Line following bots are great. Built one with lego mindstorm. Now to see if it’s possible without prefabricated modules.

    September 12, 2016 at 8:24 am

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.