The TCRT-5000 IR sensor is a compact, reflective sensor that incorporates an infrared emitter and a phototransistor in a leaded package which blocks visible light. It is widely used for proximity sensing, line following robots, and object detection, making it a popular choice in robotics and automation projects.
Pin Number | Name | Description |
---|---|---|
1 | Vcc | Power supply (3.3V to 5V) |
2 | GND | Ground connection |
3 | AO | Analog output voltage |
4 | DO | Digital output (active low) |
// Define the TCRT-5000 sensor's analog and digital pins
const int analogPin = A0; // Analog output from the sensor
const int digitalPin = 2; // Digital output from the sensor
void setup() {
pinMode(digitalPin, INPUT); // Set the digital pin as input
Serial.begin(9600); // Start serial communication at 9600 baud
}
void loop() {
int analogValue = analogRead(analogPin); // Read the analog value
int digitalValue = digitalRead(digitalPin); // Read the digital value
// Print the values to the serial monitor
Serial.print("Analog Value: ");
Serial.print(analogValue);
Serial.print("\tDigital Value: ");
Serial.println(digitalValue);
delay(100); // Wait for 100 milliseconds before the next loop
}
Q: Can the TCRT-5000 detect colors? A: The TCRT-5000 is not designed to detect colors; it detects the presence of an object based on reflected IR light.
Q: What is the maximum sensing distance of the TCRT-5000? A: The maximum sensing distance varies but is typically around a few millimeters. It can be adjusted using the onboard potentiometer.
Q: How can I increase the sensing range of the TCRT-5000? A: The sensing range can be increased by adjusting the potentiometer to increase the sensitivity or by using external optics to focus the IR light.
Q: Is the TCRT-5000 sensor waterproof? A: No, the TCRT-5000 is not waterproof. Care should be taken to protect it from moisture and other environmental factors that could damage the sensor.