Skip to main content
IR Sensor Module: Working, Wiring & Projects
Sensors

IR Sensor Module: Working, Wiring & Projects

GenBots Team 2 August 2026 7 min read 2,870 views

What is an IR Sensor?

An **Infrared (IR) Sensor Module** is a small, low-cost electronic device that detects the presence of nearby objects using infrared light. It consists of an **IR LED** (emitter) that emits infrared light and a **photodiode** (receiver) that detects reflected infrared light.


When an object comes within the sensor's range, the infrared light emitted by the LED bounces off the object and is detected by the photodiode. The onboard comparator circuit then outputs a digital signal — **LOW when an object is detected** (active low) and **HIGH when nothing is present**.

Key Specifications

ParameterValue

|---|---|

Operating Voltage3.3V – 5V DC
Detection Range2cm – 30cm (adjustable)
Output TypeDigital (HIGH/LOW)
Indicator LEDsPower LED + Signal LED
Adjust RangePotentiometer on-board
Dimensions~32mm × 14mm

The module has **3 pins**: VCC, GND, and OUT (digital output). A small onboard **potentiometer** lets you adjust the detection distance — turn clockwise to increase sensitivity.

Working Principle

1. The **IR LED** continuously emits infrared radiation (invisible to human eyes).

2. When an **object** comes in front of the sensor, the IR light reflects back.

3. The **photodiode** picks up the reflected IR signal.

4. The onboard **LM393 comparator** IC processes the signal.

5. If the reflected signal crosses the threshold (set by the potentiometer), the **OUT pin goes LOW** (object detected).

6. If no object is present, the OUT pin stays **HIGH**.


⚠️ **Note**: IR sensors work best with light-colored surfaces. Dark/black surfaces absorb infrared light and may not reflect enough signal. This property is actually useful for **line-following robots**!

Wiring with Arduino

**Connections:**

- **VCC** → Arduino 5V

- **GND** → Arduino GND

- **OUT** → Arduino Digital Pin 7


**Arduino Code:**

#define IR_PIN 7


void setup() {

Serial.begin(9600);

pinMode(IR_PIN, INPUT);

pinMode(LED_BUILTIN, OUTPUT);

}


void loop() {

int val = digitalRead(IR_PIN);


if (val == LOW) {

// Object detected!

Serial.println("Object Detected!");

digitalWrite(LED_BUILTIN, HIGH);

} else {

Serial.println("No Object");

digitalWrite(LED_BUILTIN, LOW);

}

delay(200);

}


💡 Remember: The output is **active LOW** — it goes LOW when an object is detected.

Project Ideas with IR Sensor

🏎️ **Line Following Robot**: Use 2–3 IR sensors at the bottom of a robot to detect a black line on a white surface. The sensors detect the line and the code adjusts motor direction to follow it.


🚗 **Object Counter / Visitor Counter**: Place at doorways to count people or objects passing through. Increment a counter each time the sensor triggers.


🤚 **Touchless Hand Sanitizer Dispenser**: Detect a hand near the sensor and activate a pump motor to dispense sanitizer.


📦 **Conveyor Belt Item Detection**: Detect products on a conveyor belt for automated counting or sorting.


🚙 **Edge Detection for Robots**: Mount sensors on the bottom facing downward — if the sensor stops detecting the floor (e.g., table edge), the robot stops or reverses.

Troubleshooting Common Issues

- **Sensor always shows detected**: Adjust the potentiometer to reduce sensitivity. Ensure no nearby objects are reflecting IR.

- **Doesn't detect dark objects**: This is normal! Dark surfaces absorb IR light. Use a different sensor type for dark objects (like ultrasonic).

- **Interference from sunlight**: IR sensors can be affected by direct sunlight since it contains IR components. Use indoors or add an IR filter.

- **Range too short**: Turn the potentiometer clockwise to increase detection range (max ~30cm for most modules).

- **Unstable readings**: Add a 100nF capacitor between VCC and GND close to the sensor for power filtering.

Want to buy these sensors?

GenBots offers all sensors, kits, and components at the best prices with fast delivery across India.