The IR Obstacle Detection Sensor Module is a compact and versatile tool for hobbyists and roboticists in Lahore, Pakistan. It utilizes infrared technology to detect obstacles within its adjustable range. The sensor transmits infrared light, and any reflected light indicates an object in its path. This non-contact sensing makes it ideal for various applications.
But the title promises a comparison — and the old version of this post never delivered one. So let's do it properly: what is the difference between an IR obstacle module and an IR receiver, and which one do you actually need?
They look similar — small boards with a black IR component — but they do opposite jobs:
| IR Obstacle Module | IR Receiver Module (KY-022) | |
|---|---|---|
| Job | Sends IR light out, detects the reflection | Listens for IR light from a remote |
| What it tells you | “Something is in front of me” (2–30 cm) | “The remote sent button X” |
| Output | Digital OUT — LOW on detection | Digital OUT — a 38 kHz command code |
| Used for | Obstacle avoidance, line following, hand detection | Remote control of a robot, TV, fan, LED |
| Needs | Nothing else — it makes its own IR light | A remote control to send the signal |
The one-line rule: a robot avoiding walls needs the obstacle module; a robot controlled by a remote needs the receiver. For the receiver, see our KY-022 guide and our IR receiver module guide. The rest of this post is about the obstacle module.
While the basic principle remains the same, IR obstacle detection modules can come with additional features like:

| IR Module Pin | Arduino Pin |
|---|---|
| VCC | 5V |
| GND | GND |
| OUT | D2 |
The active-LOW rule: OUT is HIGH when the path is clear and goes LOW when an obstacle is detected. This catches out everyone the first time — if your code checks if (digitalRead(2) == HIGH) for an obstacle, it will do the exact opposite of what you want. The sketch below checks for LOW.
// IR obstacle module — OUT on D2 (LOW = obstacle detected)
const int irPin = 2;
const int ledPin = 13;
const int buzzerPin = 8;
void setup() {
pinMode(irPin, INPUT);
pinMode(ledPin, OUTPUT);
pinMode(buzzerPin, OUTPUT);
Serial.begin(9600);
}
void loop() {
int detected = digitalRead(irPin);
if (detected == LOW) {
digitalWrite(ledPin, HIGH);
tone(buzzerPin, 1000);
Serial.println("Obstacle detected!");
} else {
digitalWrite(ledPin, LOW);
noTone(buzzerPin);
Serial.println("Path clear");
}
delay(200);
}Upload it, open the Serial Monitor at 9600 baud, and move your hand in front of the sensor — the LED lights and the buzzer sounds. Turn the onboard potentiometer with a small screwdriver to set the detection distance: clockwise usually increases the range. For a full robot that turns away from walls, see our obstacle avoidance robot car — the same LOW-means-obstacle logic drives the motors.
Head to the bustling halls of electronic shops in Hall Road, Lahore, or explore online stores like QKZee Technologies to find the perfect IR sensor or IR obstacle detection module for your project. Consider factors like:
The KY-022 IR receiver and the IR remote are available on order — message us on WhatsApp.
By following these guidelines, you'll be well on your way to incorporating this powerful sensor into your next robotic creation in Lahore, Pakistan!
If the module triggers with nothing there, never triggers, or works indoors but not outdoors, message us on WhatsApp and we'll help you debug it — or watch the build on our YouTube channel.
Chat on WhatsApp Watch on YouTube
Q1: Why does OUT go LOW when it detects something? Shouldn't it be HIGH?
That is how the module's comparator is wired — the output is active LOW, the same as the MQ-2 gas sensor's digital output. So check if (digitalRead(2) == LOW) for an obstacle, not HIGH. If your code does the opposite of what you expect, this is almost certainly why.
Q2: Why does it trigger with nothing in front of it?
Two usual causes: (1) the potentiometer is set to maximum range — turn it down until it stops triggering on empty air; (2) sunlight — the sun is a huge source of infrared light and can saturate the photodiode. The module is an indoor sensor; outdoors it will misbehave. Test it indoors first.
Q3: Does it work in sunlight?
Poorly. Sunlight contains strong infrared light, which floods the receiver and makes the module trigger constantly or not at all. If your robot must work outdoors, use an ultrasonic sensor (HC-SR04) instead — sound doesn't care about sunlight. See our ultrasonic sensors guide.
Q4: Why doesn't it detect a black object?
Black surfaces absorb infrared light instead of reflecting it, so little or no light comes back to the photodiode. The module detects white and light-coloured objects at the full 30 cm, but a black object may only be detected at a few centimetres — or not at all. This is normal for IR, not a fault.
Q5: Obstacle module or IR receiver — which one do I need?
Robot avoiding walls, a hand under a tap, a line follower: the obstacle module (this post). Remote-controlling a robot, fan or LED with a TV remote: the IR receiver (KY-022) — see our KY-022 guide. They are not interchangeable — the obstacle module makes its own IR light, the receiver only listens for someone else's.