Arduino B.Tech/Diploma Beginner

How to use IR Sensor Module with Arduino – Simple Guide

Interfacing IR (Infrared) Sensor Module with Arduino UNO to control LED based on object detection, proximity sensing, motion-activated alarm

  • Suitable forB.Tech/Diploma Arduino students
  • Build time1-2 weeks
  • LevelBeginner
  • Available atAjvika Labs, Kakinada

About this project

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.
Components
Quantity
Purchase Links

Arduino UNO R4/R3 Board

Amazon
AliExpress

IR Sensor Module

Amazon
AliExpress
SunFounder

LED

Amazon
AliExpress
SunFounder

220-ohm Resistor

Amazon
AliExpress
SunFounder

Connecting Wires

Amazon
AliExpress
SunFounder

Type C USB Cable

Amazon
AliExpress

Breadboard

Amazon
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.
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.
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.
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.
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.
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.
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.
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 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.
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.
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.

// Define pin numbers
const
int
ledPin
=

;
// LED connected to digital pin 5
const
int
irSensorPin
=

;
// 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
(

)
;
// 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

Technologies used

ArduinoBLE

Hardware components

  • Arduino
  • IR Sensor

Software & tools

  • Arduino IDE

What you get

  • Working project / hardware kit, tested before delivery
  • Complete source code with explanation
  • Project demo and guidance for your viva
  • Project report, PPT and IEEE paper support (on request)
Delivery & Payment
Delivery takes a minimum of two weeks from the date your inquiry is confirmed. Payment is in two parts: • 50% advance to start the project • Remaining 50% before delivery Note: • Documentation and PPT are not included by default • If you need documentation/PPT, it can be arranged for extra time and cost We'll confirm the exact timeline and cost with you after reviewing your requirements.