

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








| Pin | Name | Description |
|---|---|---|
| 1 | VCC | Power supply pin. Connect to 3.3V or 5V DC. |
| 2 | GND | Ground pin. Connect to the ground of the circuit. |
| 3 | OUT (Digital) | Digital output pin. Outputs HIGH or LOW based on object detection. |
| 4 | OUT (Analog)* | Analog output pin (if available). Provides a voltage proportional to distance. |
*Note: Some IR sensors may not have an analog output pin. Check your specific model's datasheet.
Below is an example of how to use a digital IR sensor with an Arduino UNO:
// Define the pin connected to the IR sensor's digital output
const int irSensorPin = 2; // Connect the OUT pin of the IR sensor to pin 2
const int ledPin = 13; // Built-in LED on Arduino for visual feedback
void setup() {
pinMode(irSensorPin, INPUT); // Set the IR sensor pin as input
pinMode(ledPin, OUTPUT); // Set the LED pin as output
Serial.begin(9600); // Initialize serial communication for debugging
}
void loop() {
int sensorValue = digitalRead(irSensorPin); // Read the IR sensor's 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 to stabilize readings
}
Sensor Not Detecting Objects
False Readings in Bright Light
Multiple Sensors Interfering with Each Other
Output Always HIGH or LOW
Q: Can the IR sensor detect transparent objects?
A: IR sensors may struggle with transparent objects like glass. Use a specialized sensor for such applications.
Q: What is the maximum range of an IR sensor?
A: The range depends on the model, typically between 2cm and 30cm. Check the datasheet for exact specifications.
Q: Can I use an IR sensor outdoors?
A: Yes, but performance may be affected by sunlight. Consider using an IR sensor with ambient light compensation.
Q: How do I clean the sensor?
A: Use a soft, dry cloth to clean the sensor lens. Avoid using liquids or abrasive materials.
This documentation provides a comprehensive guide to understanding and using an IR sensor effectively.