Extra 5% OFF Use Code: OL05
Free Shipping over ₹999

Project 34: Reflective Infrared Optical Sensor

Introduction

In this tutorial, we are using the TCRT5000 IR sensor module with an Arduino.
The sensor detects objects or lines by measuring reflected infrared light.
When placed over a black or white surface, it sends signals to the Arduino based on reflection.
This setup is commonly used for line follower robots and obstacle detection projects.

Required Components

  • Arduino UNO
  • TCRT5000 Sensor
  • Jumper wires
  • Breadboard

Pinout

Circuit Diagram / Wiring

  • TCRT5000 Sensor VCC → 5V (Arduino)
  • TCRT5000 Sensor GND → GND (Arduino)
  • TCRT5000 Sensor OUTPUT → A0 (Arduino)

Arduino Code / Programming

// Define the pin connected to the TCRT5000 sensor output
const int sensorPin = A0;  // Analog input pin
 
void setup() {
  Serial.begin(9600);  // Initialize serial communication
}
 
void loop() {
  // Read the analog voltage from the TCRT5000 sensor
  int sensorValue = analogRead(sensorPin);
 
  // Print the sensor value to the Serial Monitor
  Serial.print("Sensor Value: ");
  Serial.println(sensorValue);
 
  // Check if an object is detected based on sensor value
  if (sensorValue > 500) {
    Serial.println("Object Detected!");  // Print message if object is detected
  } else {
    Serial.println("No Object Detected");  // Print message if no object is detected
  }
 
  delay(500);  // Delay for stability
}

Explanation

  • The TCRT5000 sensor emits infrared light and detects how much is reflected back.
  • The Arduino reads the sensor output (analog or digital) to determine surface color or object presence.
  • It’s ideal for tasks like line tracking, edge detection, or object proximity sensing.

Troubleshooting

  • Ensure the sensor is correctly wired to 5V, GND, and the correct Arduino input pin.
  • If the sensor isn’t detecting, adjust the height and angle between the sensor and surface.
  • Test in different lighting; ambient light can interfere with infrared reflection.

    Leave a Reply

    Your email address will not be published.

    Need Help?