TCRT5000 IR Sensor

Questions, answers, feedback or just general conversation about anything to do with the store 'Hacker's Warehouse'.

TCRT5000 IR Sensor

Postby Tim Laren » Sat Mar 31, 2012 7:04 pm

The TCRT500 is an IR Emitter and Detector paired together. The detector is a IR Photo Transistor so you can read it as an analog signal or as a digital signal.

Reading it as a digital signal you get a 1 or a 0 based on the threshold of the digital input and the distance of an object to the sensor. This is good for reading teeth on a gear or the end position of a moving arm/platform/actuator. Here is a sample code to read the sensor and send the output to the serial port.

Code: Select all
/*
    TCRT5000 IR Sensor Test Digital
 Reads a digital input on pin 8, prints the result to the serial monitor
 */

void setup() {
  Serial.begin(9600);
  pinMode(8, INPUT);
}

void loop() {
  int sensorValue = digitalRead(8);
  Serial.println(sensorValue);
}


Reading it as an analog signal you get a value from 0 to 1024 based on the distance of an object to the sensor and spurious IR light hitting the sensor. This can be used as a basic distance sensor from about 1 to about 100mm. Here is a sample code to read the sensor and send the output to the serial port.

Code: Select all
/*
  TCRT5000 IR Sensor Test Analog
 Reads a analog input on pin A0, prints the result to the serial monitor
 */

void setup() {
  Serial.begin(9600);
}

void loop() {
  int sensorValue = analogRead(0);
  Serial.println(sensorValue);
}


Here is the test circuit. +V connects to the Arduino +5 power pin. Output goes to the Digital or Analog input on the Arduino. GND connects to the Power Ground pin on the Arduino

Note: I changed the following diagram on 1/8/2013 because it was in error
Image
Note: I recommend changing the resistor value to 220 or 100 ohms to emit more IR light and get better range. 100 ohms drives the emitter at about 40mA well within the spec of 60mA. (1/8/2013)

Here is the Spec Sheet for the TCRT5000
TCRT5000.pdf
TCRT5000 Spec Sheet
(309.18 KiB) Downloaded 1867 times
Image
Tim Laren
Site Admin
 
Posts: 137
Joined: Thu Mar 04, 2010 8:25 pm

Return to Hacker's Warehouse Feedback

Who is online

Users browsing this forum: No registered users and 1 guest

cron