

An infrared (IR) sensor detects infrared radiation, which is electromagnetic radiation with wavelengths longer than visible light. 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 pin configuration for a standard 3-pin IR sensor module is as follows:
| Pin | Name | Description |
|---|---|---|
| 1 | VCC | Power supply pin (3.3V to 5V) |
| 2 | GND | Ground pin |
| 3 | OUT | Output pin (Digital or Analog, depending on the model) |
Below is an example of how to connect and use an IR sensor with an Arduino UNO:
// IR Sensor Example Code
// This code reads the digital output of an IR sensor and turns on an LED
// when an object is detected.
const int irSensorPin = 2; // IR sensor output pin connected to digital pin 2
const int ledPin = 13; // Built-in LED pin on Arduino
void setup() {
pinMode(irSensorPin, INPUT); // Set IR sensor pin as input
pinMode(ledPin, OUTPUT); // Set LED pin as output
Serial.begin(9600); // Initialize serial communication
}
void loop() {
int sensorValue = digitalRead(irSensorPin); // Read the IR sensor output
if (sensorValue == HIGH) {
// Object detected
digitalWrite(ledPin, HIGH); // Turn on the LED
Serial.println("Object detected!");
} else {
// No object detected
digitalWrite(ledPin, LOW); // Turn off the LED
Serial.println("No object detected.");
}
delay(100); // Small delay for stability
}
The sensor is not detecting objects.
False detections or erratic behavior.
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 block infrared radiation, while others allow it to pass through. Test the sensor with the specific glass material in your application.
Q: What is the maximum detection range of an IR sensor?
A: The detection range varies by model, typically between 2cm and 30cm. Check the datasheet of your specific sensor for exact details.
Q: Can I use an IR sensor outdoors?
A: Yes, but be aware that strong sunlight or other IR sources may interfere with the sensor's performance. Consider using an IR filter or shielding to improve reliability.
Q: How do I differentiate between multiple IR sensors in a circuit?
A: Assign each sensor to a separate input pin on your microcontroller and handle them individually in your code.