Introduction
In the world of DIY electronics and robotics, sensing the environment is the first step toward automation. Today, we are building a simple yet powerful IR Obstacle Detection System. This project uses infrared light to detect objects in front of it without any physical contact, making it perfect for robots, security alarms, or automated switches.
Components Needed
To build this circuit, you will need the following parts:
Arduino Uno R3 (The "Brain")
FC-51 IR Obstacle Sensor Module
LED (Any color, for visual feedback)
220Ω Resistor (To protect the LED)
Breadboard
Jumper Wires (Male-to-Male and Male-to-Female)
Circuit and Connections
Follow these steps to ensure a neat and working connection:
| Sensor Pin | Arduino Pin | Wire Color |
| VCC | 5V | Red |
| GND | GND | Black |
| OUT | Digital Pin 7 | Yellow |
LED Connections:
Anode (Long Leg): Connect to Digital Pin 7.
Cathode (Short Leg): Connect to a 330Ω Resistor, then to GND.
Working of the Circuit
The FC-51 sensor has an IR transmitter (clear LED) and an IR receiver (black LED).
The transmitter constantly emits infrared light.
When an object comes in front of the sensor, the IR light reflects back.
The receiver detects this reflected light and sends a LOW (0) signal to the Arduino.
The Arduino reads this signal and triggers the external LED to turn on.
The Code
Copy and paste this code into your Arduino IDE:
// Project: IR Obstacle Detection
const int sensorPin = 7; // IR Sensor Output
const int ledPin = 9; // Indicator LED
void setup() {
pinMode(sensorPin, INPUT); // Set sensor as Input
pinMode(ledPin, OUTPUT); // Set LED as Output
Serial.begin(9600); // Start Serial Monitor
}
void loop() {
int status = digitalRead(sensorPin);
if (status == LOW) { // Object Detected
digitalWrite(ledPin, HIGH);
Serial.println("OBSTACLE DETECTED");
} else { // Path Clear
digitalWrite(ledPin, LOW);
Serial.println("PATH CLEAR");
}
delay(50);
}
Code Working
pinMode: Configures Pin 7 to listen for the sensor and Pin 9 to power the LED.
digitalRead: Constantly checks the state of the sensor.
if (status == LOW): This is crucial because the FC-51 sensor uses Active LOW logic (it sends 0 when it sees something).
Serial.println: Sends the status to your computer screen for debugging.
Calibration Tips
If your sensor is always "ON" or doesn't see anything:
Sensitivity Screw: Locate the blue potentiometer (the square component with a screw) on the sensor.
Adjustment: Use a small screwdriver. Turn it clockwise to increase the range (detect further) or counter-clockwise to decrease it.
Uses of this Circuit
Obstacle Avoiding Robots: To prevent collisions.
Touchless Switches: For hygienic light or water control.
Security Systems: To detect movement through a doorway.
Object Counters: For factory conveyor belt simulations.
Conclusion
This IR sensor project is a great "Hello World" for robotics. It’s simple, cheap, and very effective. Once you master this, you can add multiple sensors to create a fully autonomous robot that can navigate a room on its own!