Infrared Sensor (IR Avoidance)

What is an IR Sensor?
An active infrared obstacle avoidance sensor is a device that detects objects in front of it by emitting a beam of infrared light and measuring the light that reflects back. It is a fundamental component for basic collision detection in robotics.
Equipped with an IR transmitter (LED) and an IR receiver (photodiode), the module processes the reflected signals using a comparator chip like the LM393. A small potentiometer onboard allows the detection range to be calibrated between 2cm and 30cm.
Key Features
Proximity Detection
Detects obstacles directly in front of the sensor without physical contact.
Adjustable Range
Uses an onboard multi-turn potentiometer to tune detection distance from 2cm to 30cm.
Digital Output
Outputs a clean digital signal (LOW when obstacle is detected, HIGH when clear).
Ambient Light Shielding
Designed to resist interference from ordinary indoor light sources.
Low Power Draw
Consumes less than 20mA, making it suitable for direct microcontroller power.
Compact Design
Small form factor with mounting screw holes for easy physical installation.
Pin Configuration
VCC
3.3V - 5V Power Supply. Connect to your microcontroller's power output pin.
GND
Ground Connection. Connect to the common ground reference of your board.
OUT
Digital Output. Outputs a LOW level signal when an obstacle is detected, otherwise outputs HIGH.
How It Works
The Science Behind It
IR sensors work using the principle of Infrared Reflection. The module contains two primary components: an IR transmitter (an LED that emits infrared light) and an IR receiver (a photodiode sensitive to IR light).
When the emitted infrared light hits an object, a portion of it reflects back to the receiver. An onboard comparator circuit (like the LM393) checks this signal against a threshold set by the potentiometer. If the reflected light is strong enough, it triggers the output.
Light Reflection Principle:
White surfaces reflect IR well (Object Detected โ Output = LOW)
Black surfaces absorb IR waves (No Object Detected โ Output = HIGH)Wiring Tips & Best Practices
Direct Sunlight
Avoid using the sensor in direct sunlight. Sunlight contains high levels of infrared light, which will falsely trigger the receiver.
Target Color
Different colors reflect IR differently. Black objects absorb IR waves and must be closer to the sensor to trigger it compared to white objects.
Angle of Obstacle
The sensor works best when obstacles are flat and perpendicular to the beam. Angled surfaces will bounce the IR light away.
Power Decoupling
Add a 0.1ฮผF capacitor across the VCC and GND pins if you experience erratic triggering from electrical noise.
Range Calibration
To calibrate, place an obstacle at your desired maximum detection distance and turn the potentiometer until the onboard output LED just lights up.
Material Absorption
Highly porous or fabric-like materials absorb IR radiation and may escape detection. Test your targets before final deployment.