Close Menu
  • Articles
    • Learn Electronics
    • Product Review
    • Tech Articles
  • Electronics Circuits
    • 555 Timer Projects
    • Op-Amp Circuits
    • Power Electronics
  • Microcontrollers
    • Arduino Projects
    • STM32 Projects
    • AMB82-Mini IoT AI Camera
    • BLE Projects
  • IoT Projects
    • ESP8266 Projects
    • ESP32 Projects
    • ESP32 MicroPython
    • ESP32-CAM Projects
    • LoRa/LoRaWAN Projects
  • Raspberry Pi
    • Raspberry Pi Projects
    • Raspberry Pi Pico Projects
    • Raspberry Pi Pico W Projects
  • Electronics Calculator
Facebook X (Twitter) Instagram
  • About Us
  • Disclaimer
  • Privacy Policy
  • Contact Us
  • Advertise With Us
Facebook X (Twitter) Instagram Pinterest YouTube LinkedIn
How To Electronics
  • Articles
    • Learn Electronics
    • Product Review
    • Tech Articles
  • Electronics Circuits
    • 555 Timer Projects
    • Op-Amp Circuits
    • Power Electronics
  • Microcontrollers
    • Arduino Projects
    • STM32 Projects
    • AMB82-Mini IoT AI Camera
    • BLE Projects
  • IoT Projects
    • ESP8266 Projects
    • ESP32 Projects
    • ESP32 MicroPython
    • ESP32-CAM Projects
    • LoRa/LoRaWAN Projects
  • Raspberry Pi
    • Raspberry Pi Projects
    • Raspberry Pi Pico Projects
    • Raspberry Pi Pico W Projects
  • Electronics Calculator
How To Electronics
Home » How to use IR Sensor Module with Arduino – Simple Guide
Arduino Projects

How to use IR Sensor Module with Arduino – Simple Guide

Mamtaz AlamBy Mamtaz AlamUpdated:February 2, 20256 Mins Read
Share Facebook Twitter LinkedIn Telegram Reddit WhatsApp
How to use IR Sensor Module with Arduino
Share
Facebook Twitter LinkedIn Pinterest Email Reddit Telegram WhatsApp

Overview

In this guide, we will explore the interfacing of an IR Sensor Module with an Arduino UNO R4 Minima Board. An IR (Infrared) Sensor Module is a device designed to detect infrared light, commonly used in remote control systems, proximity sensors, and line-following robots.

The IR Sensor Module typically includes an infrared transmitter and receiver. The transmitter emits infrared light, and the receiver detects the reflected infrared light from nearby objects. When interfaced with an Arduino, this module allows the board to detect the presence, distance, and even the movement of objects based on infrared light reflections.

In this guide, we will go through basics of connecting the IR Sensor Module to an Arduino UNO board. We will also discuss writing the code necessary for the Arduino to interpret the signals from the IR sensor. This enables the implementation of various applications, such as object detection, proximity sensing, and motion-activated systems.


Bill of Materials

For this tutorial I am using the SunFounder Arduino Starter Kit which has 90+ components.

Here are the list of components I am using from this Kit.

S.N.ComponentsQuantityPurchase Links
1Arduino UNO R4/R3 Board1Amazon | AliExpress
2IR Sensor Module1Amazon | AliExpress | SunFounder
3LED1Amazon | AliExpress | SunFounder
4220-ohm Resistor1Amazon | AliExpress| SunFounder
5Connecting Wires10Amazon | AliExpress | SunFounder
6Type C USB Cable1Amazon | AliExpress
7Breadboard1Amazon | AliExpress | SunFounder




IR (Infrared) Sensor Module

The IR Infrared Obstacle Avoidance Sensor Module based on the LM393 IC is a specialized electronic component designed for detecting obstacles and implementing basic proximity sensing.

IR Sensor Module

An IR Obstacle Sensor operates based on the principle of infrared light reflection to detect the presence of obstacles. Under normal conditions without any obstructing object, the infrared receiver does not pick up any signals. However, when an object appears in front of the sensor, it blocks and reflects the infrared light back towards the sensor. This reflection is then detected by the infrared receiver, indicating the presence of an obstacle.

Working Principle of IR Sensor

This sensor operates on the principle of infrared reflection. When there are no obstacles in its path, the emitted infrared rays gradually diminish in intensity with increasing distance and eventually dissipate entirely.

IR Sensor Working Principle

However, the presence of an obstacle alters this behavior. As the infrared ray encounters an obstacle, it is reflected back towards the sensor. The infrared receiver then picks up this reflected signal, identifying the presence of an obstacle ahead. The range within which the sensor can detect obstacles is adjustable, thanks to the inclusion of a built-in potentiometer.


Key Components and Functionality of IR Sensor Module

An obstacle avoidance sensor is primarily composed of three components: an infrared transmitter, an infrared receiver, and a potentiometer.

  1. Infrared Emitting and Receiving Tubes: The module includes a pair of tubes; one transmits infrared light, and the other receives the reflected infrared waves. The transmitting tube emits IR light, which, upon encountering an obstacle, reflects back towards the module.
  2. LM393 Comparator IC: The core of the module is the LM393 IC, a low-power, low-offset voltage dual comparator. This IC is responsible for comparing the intensity of the received IR light with a reference value to determine the presence of an obstacle.
  3. Green Indicator LED: When the reflected IR waves are detected by the receiving tube, the comparator IC processes this information. If the received signal meets the threshold set by the module, it triggers the green LED to light up, indicating obstacle detection.
  4. Adjustable Sensitivity: The module typically includes a potentiometer to adjust the sensitivity of the sensor. By tuning this potentiometer, users can set the threshold distance for obstacle detection, making the module versatile for different applications.
  5. Output Signal: When an obstacle is detected within the preset range, the module outputs a digital signal. This signal can be fed to a microcontroller like an Arduino for further processing and integration into larger systems.

IR Sensor Module Schematic

IR Sensor Module Schematic



IR Sensor Module Pinout

The pinout of a typical IR (Infrared) Sensor Module is straightforward, usually consisting of three main pins that are crucial for its operation and interfacing with other devices like microcontrollers.

IR Sensor Module Pinout

  • VCC: Power Supply – Connects to the power source, typically 3.3V to 5V.
  • GND: Ground Pin.
  • DO: Digital Output – Outputs a digital signal (high/low) indicating obstacle detection.

Interfacing IR Sensor Module with Arduino

Now let’s interface the IR Sensor Module with Arduino to create an Obstacle Detection System. Here is the simple connection guide.

Begin by connecting the IR sensor’s VCC pin to the 5V output on the Arduino for power. Then, connect the GND pin of the IR sensor to one of the GND pins on the Arduino. Finally, connect the Digital Output Pin (DO) to a digital pin (such as D2) on the Arduino.

Breadboard Interfacing IR Sensor Module with Arduino

For visual indication, you can use an LED connected to another digital pin (e.g., D3) of the Arduino via a 220-ohm resistor.


Source Code/Program

The coding part of the project is done in the Arduino programming environment. Let’s look at the code for interfacing the IR Sensor Module with an Arduino UNO. The code is straightforward.

This project is an obstacle detection system. The main idea is to use an IR sensor module to detect the presence of an object. When an object is detected within a certain range of the sensor, the LED is switched on. Conversely, when no object is detected, or it is beyond the sensing range, the LED remains off. The range can be adjusted via the sensor’s built-in potentiometer, and digital or analog signals can be used to determine the presence and proximity of the obstacle.



1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
// Define pin numbers
const int ledPin = 3;        // LED connected to digital pin 5
const int irSensorPin = 2;   // IR Sensor connected to digital pin 2
 
void setup() {
  pinMode(ledPin, OUTPUT);      // Set the LED pin as output
  pinMode(irSensorPin, INPUT);  // Set the IR sensor pin as input
}
 
void loop() {
  int sensorState = digitalRead(irSensorPin); // Read the state from the IR sensor
 
  // The sensor outputs LOW when it detects an obstacle
  if (sensorState == LOW) {  
    digitalWrite(ledPin, HIGH);  // Turn the LED on
  } else {
    digitalWrite(ledPin, LOW);   // Turn the LED off
  }
 
  delay(100);  // Wait for 100 milliseconds
}


Testing the IR Sensor Arduino Project Working

After uploading the code to the Arduino UNO Board, the device is ready for testing.

To test it, place the IR Sensor in an environment with potential obstacles. If there is no object within the sensor’s range, the LED remains off.

If an object is detected within the sensing range of the IR sensor, the LED is switched on. You can test this by moving your hand or an object in front of the IR sensor.

This is how you can use an IR Sensor Module with Arduino to create an Obstacle Detection System. The sensor can detect objects within its range and respond accordingly, demonstrated by the LED’s activation in the presence of an obstacle.


Some Projects using IR Sensor Module

  • IR Based Fan Speed Measurement
  • Digital Tachometer with IR Sensor
  • Bidirectional Visitor Counter with IR Sensor
Share. Facebook Twitter Pinterest LinkedIn Tumblr Email Reddit Telegram WhatsApp
Previous ArticleHow to use LDR Sensor Module with Arduino
Next Article IoT Solar Panel Monitoring System with ESP8266 & MQTT

Related Posts

DC Energy Meter using Arduino

Build a DC Energy Meter using Arduino – 32V/5A

Updated:August 26, 20252K
Interfacing ADXL375 Accelerometer with Arduino

Interfacing ADXL375 Accelerometer with Arduino (±200g)

Updated:June 28, 2025
PZEM-004T Arduino Energy Meter

DIY AC Energy Meter using PZEM-004T & Arduino

Updated:March 6, 20258K
Interfacing BMI160 Accelerometer & Gyroscope with Arduino

Interfacing BMI160 Accelerometer & Gyroscope with Arduino

Updated:February 2, 20259K
Password Based Door Lock Security System Using Arduino & Keypad

Password Based Door Lock Security System Using Arduino & Keypad

Updated:February 2, 20252436K
Earthquake Detector Alarm with with Accelerometer & Arduino

Earthquake Detector Alarm with Accelerometer & Arduino

Updated:February 2, 2025661K
Add A Comment

CommentsCancel reply

Latest Posts
ESP32 Fingerprint Attendance System with Live Web Dashboard

ESP32 Fingerprint Attendance System with Live Web Dashboard

June 21, 2026
IoT Based PM & Air Quality Monitoring System using ESP32

IoT Based PM & Air Quality Monitoring System using ESP32

June 14, 2026
DIY ESP32 MLX90640 IR Thermal Camera with Live Web Display

DIY ESP32 MLX90640 IR Thermal Camera with Live Web Display

May 10, 2026
IoT Activity Tracker with ESP32 & Accelerometer Gyroscope

IoT Activity Tracker with ESP32 & Accelerometer/Gyroscope

May 2, 2026
A Guide to Sourcing Obsolete ICs for Vintage Projects

Beyond AliExpress: A Guide to Sourcing Obsolete ICs for Vintage Projects

April 21, 2026

ESP32 IoT Vehicle Motion Analyzer with MPU6050 & LIS3MDL

April 27, 2026
Building a Smart Sensor Node with a BLE Microcontroller

Building a Smart Sensor Node with a BLE Microcontroller

February 26, 2026
High-Accuracy Pitch, Roll, Yaw with ESP32 & BNO08x IMU

High-Accuracy Pitch, Roll, Yaw with ESP32 & BNO08x IMU

April 27, 2026
Top Posts & Pages
  • ESP32 Fingerprint Attendance System with Live Web Dashboard
    ESP32 Fingerprint Attendance System with Live Web Dashboard
  • IoT AC Energy Meter with PZEM-004T & ESP32 WebServer
    IoT AC Energy Meter with PZEM-004T & ESP32 WebServer
  • 12V DC to 220V AC Inverter Circuit & PCB
    12V DC to 220V AC Inverter Circuit & PCB
  • ESP32 CAN Bus Tutorial | Interfacing MCP2515 CAN Module with ESP32
    ESP32 CAN Bus Tutorial | Interfacing MCP2515 CAN Module with ESP32
  • How to use Modbus RTU with ESP32 to read Sensor Data
    How to use Modbus RTU with ESP32 to read Sensor Data
  • IoT Based ECG Monitoring with AD8232 ECG Sensor & ESP32
    IoT Based ECG Monitoring with AD8232 ECG Sensor & ESP32
  • MAX30102 & Arduino: Heart Rate + Blood Oxygen Monitoring
    MAX30102 & Arduino: Heart Rate + Blood Oxygen Monitoring
  • Buck Converter: Basics, Working, Design & Application
    Buck Converter: Basics, Working, Design & Application
Categories
  • Arduino Projects (197)
  • Articles (60)
    • Learn Electronics (19)
    • Product Review (15)
    • Tech Articles (28)
  • Electronics Circuits (46)
    • 555 Timer Projects (21)
    • Op-Amp Circuits (7)
    • Power Electronics (13)
  • IoT Projects (205)
    • ESP32 MicroPython (7)
    • ESP32 Projects (82)
    • ESP32-CAM Projects (15)
    • ESP8266 Projects (76)
    • LoRa/LoRaWAN Projects (22)
  • Microcontrollers (38)
    • AMB82-Mini IoT AI Camera (4)
    • BLE Projects (18)
    • STM32 Projects (19)
  • Raspberry Pi (93)
    • Raspberry Pi Pico Projects (57)
    • Raspberry Pi Pico W Projects (12)
    • Raspberry Pi Projects (24)
Follow Us
  • Facebook
  • Twitter
  • Pinterest
  • Instagram
  • YouTube
About Us

“‘How to Electronics’ is a vibrant community for electronics enthusiasts and professionals. We deliver latest insights in areas such as Embedded Systems, Power Electronics, AI, IoT, and Robotics. Our goal is to stimulate innovation and provide practical solutions for students, organizations, and industries. Join us to transform learning into a joyful journey of discovery and innovation.

Copyright © How To Electronics. All rights reserved.
  • About Us
  • Disclaimer
  • Privacy Policy
  • Contact Us
  • Advertise With Us

Type above and press Enter to search. Press Esc to cancel.

Ad Blocker Enabled!
Ad Blocker Enabled!
Looks like you're using an ad blocker. Please allow ads on our site. We rely on advertising to help fund our site.