

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, line-following robots, and remote control systems. These sensors are valued for their simplicity, low cost, and versatility in detecting objects or signals.
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 | 2 cm to 30 cm (varies by model) |
| Output Type | Digital (High/Low) or Analog |
| Wavelength Sensitivity | ~940 nm (infrared spectrum) |
| Response Time | ~10 ms |
| 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 signal, depending on model) |
Below is an example of how to connect and use an IR sensor with an Arduino UNO:
// IR Sensor Example Code for Arduino UNO
// This code reads the digital output of the IR sensor and turns on an LED
// when an object is detected.
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
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 being read by the microcontroller:
Q: Can the IR sensor detect transparent objects?
A: IR sensors may struggle to detect transparent objects like glass, as they allow most IR light to pass through. Use alternative sensing methods for such applications.
Q: How do I increase the detection range of the IR sensor?
A: You can adjust the potentiometer (if available) on the sensor module to increase the detection range. However, note that increasing the range may reduce accuracy.
Q: Can I use the IR sensor outdoors?
A: While IR sensors can be used outdoors, they may be affected by sunlight or other IR sources. Consider using shielding or modulation techniques to improve performance in outdoor environments.