

An IR (Infrared) sensor is an electronic device that detects infrared radiation emitted by objects. It is widely used in various applications such as proximity sensing, motion detection, and remote control systems. IR sensors are versatile and can be used in both analog and digital modes, making them suitable for a wide range of projects, from robotics to home automation.
Common applications of IR sensors include:








Below are the key technical details of 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 | 760nm to 1100nm (Infrared range) |
| Response Time | < 2ms |
| Operating Temperature | -25°C to 85°C |
The IR sensor module typically has three or more pins. Below is the pin configuration for a common 3-pin IR sensor module:
| Pin | Name | Description |
|---|---|---|
| 1 | VCC | Power supply pin (3.3V to 5V) |
| 2 | GND | Ground pin |
| 3 | OUT | Output pin (Digital or Analog signal based on model) |
For modules with additional pins, such as an EN (Enable) pin or sensitivity adjustment, refer to the specific datasheet.
Below is an example of how to use an IR sensor with an Arduino UNO to detect an object and turn on an LED:
// Define pin connections
const int irSensorPin = 2; // IR sensor output connected to digital pin 2
const int ledPin = 13; // Built-in LED 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 == LOW) { // Object detected (LOW signal from sensor)
digitalWrite(ledPin, HIGH); // Turn on the LED
Serial.println("Object detected!");
} else { // No object detected (HIGH signal from sensor)
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 triggers or erratic behavior:
Output signal is not as expected:
Q: Can the IR sensor detect transparent objects?
A: IR sensors may struggle to detect transparent or translucent objects. Use a sensor specifically designed for such applications.
Q: How do I increase the detection range?
A: Adjust the potentiometer on the sensor module (if available). For fixed-range sensors, consider using a model with a longer detection range.
Q: Can I use the IR sensor outdoors?
A: While possible, outdoor use may result in reduced accuracy due to sunlight interference. Use an IR sensor with ambient light filtering for better performance.
Q: What is the difference between analog and digital IR sensors?
A: Analog IR sensors provide a continuous voltage output proportional to the distance of the object, while digital IR sensors output a HIGH or LOW signal based on a threshold distance.
By following this documentation, you can effectively integrate an IR sensor into your projects and troubleshoot common issues.