

An IR (Infrared) sensor is an electronic device that detects infrared radiation emitted by objects. It is widely used in applications such as motion detection, proximity sensing, and remote control systems. IR sensors are versatile and can be found in devices like automatic doors, burglar alarms, and even TV remote controls. They are valued for their ability to detect objects or measure distances without physical contact.








Below are the key technical details of a typical IR sensor:
The IR sensor typically has three pins. The table below describes each pin:
| Pin Number | Pin Name | Description |
|---|---|---|
| 1 | VCC | Power supply pin (3.3V to 5V DC) |
| 2 | GND | Ground pin |
| 3 | OUT | Output pin (Digital or Analog signal) |
Note: Some IR sensors may have additional pins for sensitivity adjustment or mode selection. Refer to the specific datasheet for your sensor 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 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 == LOW) {
// Object detected (LOW signal from IR sensor)
digitalWrite(ledPin, HIGH); // Turn on the LED
Serial.println("Object detected!");
} else {
// No object detected (HIGH signal from IR 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 always HIGH or LOW:
Q: Can the IR sensor detect transparent objects?
A: IR sensors may struggle to detect transparent or reflective objects. Use specialized sensors for such applications.
Q: What is the difference between digital and analog IR sensors?
A: Digital IR sensors provide a HIGH/LOW output, while analog IR sensors output a voltage proportional to the detected object's distance.
Q: Can I use an IR sensor outdoors?
A: Yes, but you must account for sunlight interference, which can affect performance. Use an IR sensor with ambient light filtering for better results.