

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 motion detection, proximity sensing, 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 | 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 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 pin |
| 3 | OUT | Output pin (Digital or Analog, depending on the model) |
VCC pin to a 3.3V or 5V power supply and the GND pin to the ground of your circuit.OUT pin to a microcontroller's input pin (e.g., Arduino) or to another circuit component that processes the sensor's output.OUT pin will typically go HIGH (logic 1) when an object is detected and LOW (logic 0) otherwise.Below is an example of how to connect and use an IR sensor with an Arduino UNO:
VCC pin of the IR sensor to the 5V pin on the Arduino.GND pin of the IR sensor to the GND pin on the Arduino.OUT pin of the IR sensor to digital pin 2 on the Arduino.// 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; // Onboard LED pin
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.
VCC and GND connections).False detections or erratic behavior.
The output signal is not changing.
OUT pin is connected to the correct input pin on the microcontroller.Q: Can the IR sensor detect transparent objects?
A: IR sensors may struggle to detect transparent or highly reflective objects, as these materials can refract or reflect infrared light unpredictably.
Q: What is the difference between digital and analog IR sensors?
A: Digital IR sensors provide a binary output (HIGH/LOW) based on object detection, while analog IR sensors output a continuous voltage proportional to the distance of the detected object.
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 outdoor applications.