Overview

Infrared (IR) sensors use infrared light reflection to detect obstacles and objects. They're perfect for robot navigation, obstacle avoidance, and proximity detection. The sensor emits infrared light and measures the reflection to determine if an object is present within its detection range. These sensors are cost-effective and reliable for short-range object detection applications.

Technical Specifications

Operating Voltage: 3.3V - 5V DC
Operating Current: 20mA
Detection Range: 2cm - 30cm
Detection Angle: 35°
IR Wavelength: 950nm
Output: Analog & Digital
Response Time: < 300 µs
Operating Temperature: -25 °C to +80 °C

Key Features

  • Infrared light-based object detection
  • Adjustable detection range via potentiometer
  • Fast response time for real-time applications
  • Dual output: analog and digital signals
  • LED indicator for detection status
  • Immune to visible light interference
  • Low power consumption
  • Compact size for easy integration

Wiring Diagram

Basic Connection (Arduino Uno)

IR Sensor Pin Arduino Pin
VCC 5V (or 3.3V)
GND GND
AO (Analog) Analog Pin A0
DO (Digital) Digital Pin 2

Note: Adjust the onboard potentiometer to set the desired detection distance.

Common Applications

Robot Navigation

Obstacle avoidance for autonomous robots

Object Detection

Proximity sensing and object counting

Line Following

Line detection for robot path following

Security Systems

Perimeter monitoring and intrusion detection

Quick Info

Difficulty: Beginner
Price Range: ₹50-150
Interface: Analog/Digital

Sample Code

#define IR_DIGITAL 2
#define IR_ANALOG A0
#define LED_PIN 13

void setup() {
  Serial.begin(9600);
  pinMode(IR_DIGITAL, INPUT);
  pinMode(LED_PIN, OUTPUT);
  
  Serial.println("IR Obstacle Sensor Test");
}

void loop() {
  int digitalValue = digitalRead(IR_DIGITAL);
  int analogValue = analogRead(IR_ANALOG);
  
  if (digitalValue == LOW) {
    digitalWrite(LED_PIN, HIGH);
    Serial.println("Obstacle Detected!");
  } else {
    digitalWrite(LED_PIN, LOW);
    Serial.println("Path Clear");
  }
  
  Serial.print("IR Reflection: ");
  Serial.println(analogValue);
  
  delay(300);
}