

An infrared (IR) object sensor detects the presence of objects by emitting infrared light and measuring the reflection. It is a versatile and cost-effective component widely used in automation, robotics, and security systems. The sensor is ideal for applications such as obstacle detection in robots, proximity sensing in automated doors, and object counting in conveyor systems.








The IR object sensor typically consists of an IR LED (emitter) and a photodiode or phototransistor (receiver). Below are the key technical details:
The IR object sensor typically has three or four pins. Below is a table describing the pin configuration for a common 3-pin IR object sensor:
| 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 | Output pin. Provides a digital signal (HIGH when no object, LOW when detected). |
For a 4-pin IR object sensor with both digital and analog outputs, the configuration is as follows:
| 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 | DOUT | Digital output pin. Provides a HIGH/LOW signal based on object detection. |
| 4 | AOUT | Analog output pin. Provides a voltage proportional to the distance of the object. |
Below is an example of how to connect and use a 3-pin IR object sensor with an Arduino UNO:
// IR Object Sensor Example Code
// This code reads the digital output of the IR sensor and turns on an LED
// when an object is detected.
const int sensorPin = 2; // Pin connected to the IR sensor's OUT pin
const int ledPin = 13; // Pin connected to the onboard LED
void setup() {
pinMode(sensorPin, INPUT); // Set the sensor pin as input
pinMode(ledPin, OUTPUT); // Set the LED pin as output
Serial.begin(9600); // Initialize serial communication
}
void loop() {
int sensorValue = digitalRead(sensorPin); // Read the 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
}
Sensor Not Detecting Objects:
False Detections:
Unstable Output:
Q1: Can the IR object sensor detect transparent objects?
A1: No, most IR object sensors cannot reliably detect transparent objects like glass, as they do not reflect sufficient infrared light.
Q2: What is the maximum detection range of the sensor?
A2: The detection range varies by model but is typically between 2cm and 30cm. Check the datasheet for your specific sensor.
Q3: Can I use the sensor outdoors?
A3: While the sensor can be used outdoors, direct sunlight may interfere with its operation. Use shielding or place the sensor in a shaded area for better performance.
Q4: How do I clean the sensor?
A4: Use a soft, dry cloth to clean the sensor lens. Avoid using water or harsh chemicals.
By following this documentation, you can effectively integrate and troubleshoot an IR object sensor in your projects.