Blog

IR Sensor Infrared Obstacle Avoidance Module

IR Infrared Obstacle Avoidance Sensor Module

Reliable Object Detection for Robotics and Automation Projects

Introduction

The IR Obstacle Avoidance Sensor is a reflective photoelectric detection module that uses infrared light to detect objects within 2-30cm. With adjustable sensitivity and digital output, it's ideal for robot navigation, object counting, and automation systems.

IR Sensor Module

Key Features

🔴 Infrared Detection

850nm IR LED with phototransistor receiver

🎚️ Adjustable Range

2cm-30cm detection (via potentiometer)

Digital Output

TTL-level signal (0V or VCC)

🔋 Low Power

Typical current: 15-20mA

Technical Specifications

Operating Voltage 3.3V – 5V DC
Detection Range 2cm – 30cm (adjustable)
Output Type Digital (High/Low)
Response Time <2ms
IR Wavelength 850nm
Interface 3-pin (VCC, GND, OUT)

Pin Configuration

IR Sensor Pinout
Pin Label Description Arduino Connection
1 VCC Power (3.3V-5V) 5V
2 GND Ground GND
3 OUT Digital Output D2 (Digital Pin)
Note: Blue potentiometer adjusts detection sensitivity

Wiring Diagram (Arduino)

// Basic Connections:
// VCC → 5V
// GND → GND
// OUT → D2 (or any digital pin)

// For best results:
// - Mount sensor 5-10cm above surface
// - Avoid direct sunlight interference

Basic Detection Example

const int IRSensor = 2; // Connected to OUT pin

void setup() {
  Serial.begin(9600);
  pinMode(IRSensor, INPUT);
}

void loop() {
  int obstacle = digitalRead(IRSensor);
  
  if (obstacle == LOW) {
    Serial.println("Obstacle detected!");
    // Add your response code here
  }
  delay(100);
}

Advanced Applications

Analog Reading (Optional)

// Connect OUT to analog pin
int sensorValue = analogRead(A0);
// Higher values = closer objects
// Requires threshold calibration

Multiple Sensors

// Array of sensor pins
int sensorPins[] = {2,3,4,5};

void setup() {
  for(int i=0; i<4; i++) {
    pinMode(sensorPins[i], INPUT);
  }
}

Debouncing

// Software debounce
unsigned long lastDetect = 0;
const int debounceDelay = 50;

if(digitalRead(IRSensor) == LOW && 
   millis() - lastDetect > debounceDelay) {
  lastDetect = millis();
  // Trigger action
}

Robot Navigation

// Simple obstacle avoidance
if(digitalRead(leftSensor) == LOW) {
  turnRight();
}
else if(digitalRead(rightSensor) == LOW) {
  turnLeft();
}
else {
  moveForward();
}

Troubleshooting

No Detection

  • Adjust potentiometer clockwise to increase sensitivity
  • Check IR LED is emitting (view through phone camera)
  • Verify object is within 2-30cm range

False Triggers

  • Reduce sensitivity (turn potentiometer CCW)
  • Shield from ambient IR sources
  • Add software debouncing

Inconsistent Readings

  • Ensure stable power supply
  • Check for loose connections
  • Test with different surface reflectivity