Obstacle Detector with Infrared Sensor and Arduino code


Welcome to the world of Arduino and obstacle detection! In this guide, we’ll explore how to build an Obstacle Detector with Infrared Sensor and Arduino code. This project opens up a realm of possibilities, from creating autonomous robots to enhancing home security systems. Let’s dive in and discover the magic of IR obstacle detection! Join us on this journey as we unravel the magic behind IR obstacle detection and its practical applications in various domains.

Hardware Required

You will require the following Hardware Components for the Obstacle Detector with Infrared Sensor and Arduino code.

Components#Buy From Amazon
Arduino UNO1Buy Link
IR Obstacle Avoidance Sensor1Buy Link
9v DC Adapter (Optional)1Buy Link
Jumper Wires3Buy Link
Breadboard1Buy Link

What is an IR Obstacle Detector?

An infrared obstacle detector is a device designed to identify the presence of objects by detecting the reflection they generate in infrared (IR) light. The utilization of IR light ensures that it remains invisible to humans.

Fundamentally, these detectors consist of basic sensors. They typically comprise an LED that emits infrared light and a photodiode (such as type BPV10NF or equivalent) that detects the light reflected by potential obstacles.


Obstacle detectors are typically equipped with a standard measurement board featuring the LM393 comparator. This component enables the acquisition of readings as digital values once a predetermined threshold is surpassed, a threshold adjusted by a potentiometer situated on the board.

These sensors operate effectively at short distances, typically ranging from 5 to 20mm. However, their precision is limited due to variations in the amount of infrared light received, influenced by factors such as the color, material, shape, and position of the obstacle. As a result, they are not suitable for providing precise distance estimates.

Despite this limitation, they find widespread use in obstacle detection for small vehicles or robots. Their affordability encourages their placement around the perimeter, allowing for obstacle detection from various directions.

Moreover, these detectors serve various other applications. They can detect the presence of objects within a defined area, determine the status of a door (open or closed), or ascertain if a machine has reached a specific point in its movement.



Pin Configuration

Pin NamePin Type
VCCPositive supply Pin
GNGGround Pin
OutOutput Pin

Circuit Diagram

The following circuit shows you the connection of the Obstacle Detector with Infrared Sensor and Arduino code, Please make the connection carefully


Circuit Connections

Vcc+5V Pin
OutD9 Pin

Installing Arduino IDE Software

First, you will require to Download the updated version of Arduino IDE Software and Install it on your PC or laptop. if you Learn How to install the Arduino step-by-step guide then click on how to install Arduino Button given Blow


//For more Projects: www.arduinocircuit.com

const int sensorPin = 9;

void setup() {
  Serial.begin(9600); //start serial port
  pinMode(sensorPin , INPUT); //define pin as input
void loop(){
  int value = 0;
  value = digitalRead(sensorPin ); //digital pin reading
  if (value == HIGH) {
      Serial.println("Obstacle detected");


  1. Robotics: Implement IR obstacle detectors in robotic systems to enable obstacle avoidance capabilities. Robots equipped with these sensors can navigate complex environments autonomously, avoiding collisions with obstacles in their path.
  2. Home Automation: Integrate IR obstacle detectors into home automation systems for enhanced safety and convenience. For instance, use them to detect obstacles near automated doors or windows, preventing accidents and ensuring smooth operation.
  3. Security Systems: Incorporate IR obstacle detectors into security systems to detect intruders or unauthorized access. These sensors can trigger alarms or alerts when they detect obstructions in restricted areas, enhancing security measures.
  4. Automotive Safety: Install IR obstacle detectors in vehicles to assist drivers in parking or maneuvering in tight spaces. These sensors can provide proximity alerts, helping drivers avoid collisions with obstacles such as walls or other vehicles.


In conclusion, the IR obstacle detector, paired with Arduino, offers a versatile solution for detecting obstacles in various applications. Whether it’s in robotics, home automation, security systems, automotive safety, or industrial automation, these sensors play a crucial role in enhancing safety, efficiency, and autonomy. As you embark on your projects.

Leave a Comment