

An infrared (IR) sensor detects infrared radiation, which is invisible to the human eye but can be emitted by objects as heat or transmitted by IR LEDs. IR sensors are widely used in various applications, including proximity sensing, motion detection, and remote control systems. These sensors are versatile, cost-effective, and easy to integrate into electronic circuits, making them a popular choice for hobbyists and professionals alike.
Common applications of IR sensors include:








Below are the general technical specifications for a typical IR sensor module:
| Parameter | Value |
|---|---|
| Operating Voltage | 3.3V to 5V |
| Operating Current | 20mA (typical) |
| Detection Range | 2cm to 30cm (varies by model) |
| Output Type | Digital (High/Low) or Analog |
| Wavelength Sensitivity | ~940nm (infrared spectrum) |
| Response Time | ~10ms |
| Operating Temperature | -25°C to 85°C |
The IR sensor module typically has three pins. Below is the pin configuration:
| Pin | Name | Description |
|---|---|---|
| 1 | VCC | Power supply pin (3.3V to 5V) |
| 2 | GND | Ground connection |
| 3 | OUT | Output pin (Digital or Analog, depending on the model) |
Below is an example of how to use an IR sensor with an Arduino UNO to detect an object and turn on an LED when the object is detected.
// Define the pin numbers for the IR sensor and LED
const int irSensorPin = 2; // IR sensor output pin connected to digital pin 2
const int ledPin = 13; // LED connected to digital pin 13
void setup() {
pinMode(irSensorPin, INPUT); // Set the IR sensor pin as input
pinMode(ledPin, OUTPUT); // Set the LED pin as output
Serial.begin(9600); // Initialize serial communication for debugging
}
void loop() {
int sensorValue = digitalRead(irSensorPin); // Read the IR sensor output
if (sensorValue == HIGH) {
// Object detected, turn on the LED
digitalWrite(ledPin, HIGH);
Serial.println("Object detected!");
} else {
// No object detected, turn off the LED
digitalWrite(ledPin, LOW);
Serial.println("No object detected.");
}
delay(100); // Small delay for stability
}
The sensor is not detecting objects.
False detections or erratic behavior.
The output signal is not changing.
Q: Can the IR sensor detect objects through glass?
A: It depends on the type of glass. Some glass materials may block or reflect infrared radiation, reducing the sensor's effectiveness.
Q: What is the maximum detection range of an IR sensor?
A: The detection range varies by model but is typically between 2cm and 30cm. Check the datasheet for your specific sensor.
Q: Can I use an IR sensor outdoors?
A: While IR sensors can be used outdoors, they may be affected by sunlight and other environmental factors. Consider using an IR sensor with ambient light filtering for better performance.
Q: How do I differentiate between multiple IR sensors in a circuit?
A: Assign each sensor to a unique input pin on your microcontroller and handle them separately in your code.