Avoid Sensor

The Obstacle Avoidance Sensor Module is a popular sensor used in robotics and automation projects to detect objects or obstacles in front of the sensor. It utilizes infrared (IR) technology to sense the presence of objects and provides a digital output signal to the Arduino, making it an excellent choice for obstacle detection and collision avoidance. In this step-by-step guide, we’ll show you how to set up the Obstacle Avoidance Sensor Module with an Arduino and create projects that navigate through obstacles with ease.

Materials Needed:

  1. Arduino board (e.g., Arduino Uno, Arduino Nano)
  2. Obstacle Avoidance Sensor Module
  3. Breadboard and jumper wires
  4. USB cable for Arduino
  5. Computer with the Arduino IDE installed (https://www.arduino.cc/en/software)

Step 1: Wiring

Connect the Obstacle Avoidance Sensor Module to the Arduino board as follows:

  • Connect the module’s VCC (Voltage) pin to the 5V pin on the Arduino.
  • Connect the module’s GND (Ground) pin to the GND pin on the Arduino.
  • Connect the module’s OUT (Digital Output) pin to a digital pin on the Arduino (e.g., D2).

Step 2: Arduino Code

Open the Arduino IDE and create a new sketch. Then, enter the following code:

const int obstacleSensorPin = 2; // Digital pin connected to the Obstacle Avoidance Sensor module

void setup() {
  pinMode(obstacleSensorPin, INPUT); // Set the Obstacle Sensor pin as INPUT
  Serial.begin(9600); // Initialize serial communication for debugging (optional)

void loop() {
  int obstacleValue = digitalRead(obstacleSensorPin); // Read the digital value from the Obstacle Sensor
  if (obstacleValue == LOW) {
    Serial.println("Obstacle detected!"); // Display a message when an obstacle is detected
    // Your custom actions or functions can be added here.
  } else {
    Serial.println("No obstacle detected."); // Display a message when no obstacle is detected

  delay(100); // Add a small delay to avoid rapid repeated detections

Step 3: Uploading the code

Connect your Arduino board to the computer using the USB cable and select the appropriate board and port from the Arduino IDE. Then, click the “Upload” button to upload the code to the Arduino.

Step 4: Observing Obstacle Detection

Once the code is uploaded successfully, open the Serial Monitor from the Arduino IDE (Ctrl + Shift + M). The Serial Monitor will display “Obstacle detected!” whenever an object or obstacle is in front of the Obstacle Avoidance Sensor Module. It will show “No obstacle detected.” when no obstacle is present.

Step 5: Experiment and Navigate

Now that the Obstacle Avoidance Sensor Module is set up and detecting obstacles, you can experiment by moving objects in front of the sensor to observe the response. You can use this sensor in robotics projects to navigate robots through complex environments while avoiding collisions.

Congratulations! You’ve successfully set up and used the Obstacle Avoidance Sensor Module with Arduino. This versatile sensor allows you to detect obstacles and respond accordingly, making it an essential component for robotic projects and obstacle avoidance systems. Have fun experimenting and incorporating the Obstacle Avoidance Sensor Module into your Arduino projects to enable obstacle detection and smooth navigation!


Leave a reply

Your email address will not be published. Required fields are marked *



Log in with your credentials


Forgot your details?


Create Account