Skip to content
Buy 10+ on select items — save 10% auto-applied
Free US shipping on orders $35+
Order by 3pm ET — ships same-day from the US
Skip to main content

Arduino IR Obstacle Sensor: Blink LED on Detect | ShillehTek

May 15, 2026 17 views

Arduino IR Obstacle Sensor: Blink LED on Detect | ShillehTek
Project

Build an Arduino IR obstacle sensor trigger that blinks the onboard LED and prints Serial alerts using a simple HIGH/LOW output module from ShillehTek.

15 min Beginner3 parts

Project Overview

Arduino + IR Obstacle Avoidance Sensor: In this build, you will wire an IR obstacle avoidance sensor module to an Arduino (like the Arduino Nano) so the built-in LED turns on and the Serial Monitor prints a message when an object is detected.

The module has an IR LED that fires forward, a phototransistor that catches the reflection, and an on-board comparator that outputs a clean HIGH/LOW signal. Adjust the detection threshold with the trim-pot to set the approximate trigger range (about 2 to 30 cm depending on surface and lighting).

  • Time: ~15 minutes
  • Skill level: Beginner
  • What you will build: An Arduino that blinks an LED when something gets within range of the IR sensor.
IR obstacle avoidance sensor module used with Arduino for object detection
IR obstacle module with IR LED, phototransistor, comparator, status LED, and trim-pot.

Parts List

From ShillehTek

External

  • USB cable - to power/program the Arduino
  • Arduino IDE - to upload the sketch and view Serial Monitor output

Note: This is a binary (yes/no) obstacle sensor, not a distance measurement sensor. For true distance measurement, use HC-SR04 (budget) or VL53L0X (more precise).

Step-by-Step Guide

Step 1 - Inspect the Module

Goal: Identify the sensor parts and the adjustment you will tune later.

What to do: Locate the IR LED (clear) and phototransistor (black) facing forward. Find the trim-pot, which adjusts the comparator threshold used to decide when the output triggers.

Close-up of IR obstacle avoidance sensor module showing IR LED, phototransistor, and trim-pot
IR LED (clear) and phototransistor (black) face forward; trim-pot adjusts threshold.

Expected result: You can identify VCC, GND, and OUT, and you know where the sensitivity adjustment is.

Step 2 - Wire It Up

Goal: Connect power and the digital output pin to the Arduino.

What to do: Wire the module to the Arduino using these connections:

IR obstacle avoidance sensor wired to an Arduino Nano using VCC, GND, and OUT
Three pins: VCC, GND, OUT.
  • VCC -> 5 V
  • GND -> GND
  • OUT -> D2 (digital input)

Expected result: The sensor is powered and its OUT pin is connected to Arduino digital pin D2.

Step 3 - Understand What the Output Means

Goal: Know how the module decides when an obstacle is detected.

What to do: Use the diagram below as a reference. The IR LED emits light, the phototransistor receives reflections, and the comparator switches the OUT pin based on the trim-pot threshold. In this module, the output goes LOW when reflection exceeds the set threshold (active-low detection).

Schematic showing IR LED and phototransistor feeding an LM393 comparator with trim-pot threshold and active-low OUT
IR LED + phototransistor + LM393 comparator + threshold pot. Output goes LOW when reflection exceeds threshold.

Expected result: You understand why the code checks for LOW to indicate an object is detected.

Step 4 - Upload the Arduino Sketch

Goal: Read the sensor output and drive the Arduino built-in LED when an obstacle is detected.

What to do: Open the Arduino IDE, select your board/port, paste the sketch below, and upload it.

Code:

const int IR  = 2;
const int LED = LED_BUILTIN;

void setup() {
  pinMode(IR, INPUT);
  pinMode(LED, OUTPUT);
  Serial.begin(9600);
}

void loop() {
  if (digitalRead(IR) == LOW) {   // active LOW = obstacle detected
    digitalWrite(LED, HIGH);
    Serial.println("Object detected!");
  } else {
    digitalWrite(LED, LOW);
  }
  delay(50);
}

Expected result: The sketch uploads successfully, and Serial Monitor is ready at 9600 baud.

Step 5 - Tune and Test

Goal: Adjust the trim-pot so the sensor triggers at the distance you want.

What to do: Open the Serial Monitor (9600 baud). Place your hand or an object in front of the sensor and turn the trim-pot:

  • Turn clockwise (CW) to make the sensor more sensitive (longer detection range).
  • Turn counterclockwise (CCW) for less sensitivity (shorter detection range).
Arduino Nano with IR obstacle sensor detecting a hand at close range and lighting the built-in LED
A hand about 5 cm away triggers the sensor; the Arduino built-in LED lights up.
Arduino IDE Serial Monitor showing repeated 'Object detected!' messages from IR obstacle sensor
Each detection prints a single line.

Expected result: When an object is within your tuned range, the Arduino LED turns on and the Serial Monitor prints “Object detected!”.

Step 6 - Where to Take It Next

Goal: Reuse the same sensor output logic in other projects.

What to do: Try one of these follow-on ideas using the same VCC/GND/OUT wiring and active-low logic:

  • Pair two sensors with an L298N + motors for an obstacle-avoiding robot
  • Build a hand-wave-controlled tap dispenser using the IR sensor as a trigger
  • Combine with HC-SR501 motion sensor for two-stage human detection
  • Replace door-bumper switches in a Roomba-style robot

Expected result: You have a clear next build direction that still uses a simple digital trigger signal.

Conclusion

You built an Arduino IR obstacle detection circuit using an IR obstacle avoidance sensor module, with an active-low digital output that turns on the built-in LED and prints a message when something is in front of the sensor.

Want the exact parts used in this build? Grab them from ShillehTek.com. If you want help customizing this project or building something for your product, check out our IoT consulting services.