How To Use An Infrared (IR) Sensor Module With Arduino UNO

4,675 views

The use of Infrared (IR) technology has become a common occurrence in our daily lives. From small signal transmitters in our TV remotes to sophisticated process control applications used in food production, IR technology has firmly grounded its importance in today’s world of electronics.  The main benefit of an IR sensor is its low power usage, simple design & convenient features. IR radiation lies between the electromagnetic regions of the visible & microwave spectrum. Usually, the wavelengths of these waves range from 0.7µm to 1000µm. So, in today’s tutorial, we are going to go over a step by step process on How To Use An Infrared (IR) Sensor Module With Arduino UNO.

What is an Infrared (IR) Sensor Module?

An Infrared (IR) Sensor is an electronic transducer that utilizes IR rays to sense some aspect of its surrounding. The sensor module has two main parts. IR Transmitter and IR Reciever. The IR transmitter transmits the infrared waves whereas the IR receiver receives these infrared waves. The receiver constantly sends digital data in the form of 0 or 1 to the Vout pin of the sensor. It is a multipurpose sensor that can be used for obstacle detection, basic contrasting color detection, fire detection, encoder / decoder etc.

Key Features & Specifications

  • Operating Voltage: 3.0V – 5.0V
  • Detection range: 2cm – 30cm (Adjustable using potentiometer)
  • Current Consumption:at 3.3V : ~23 mA,at 5.0V: ~43 mA
  • Active output level: Outputs Low logic level when obstacle is detected
  • On board Obstacle Detection LED indicator
  • Range: Up to 20cm
  • Adjustable Sensing range
  • Built-in Ambient Light Sensor
  • 20mA supply current
  • Mounting hole

Hardware Component

You will need the following parts to build this project:

S.NoComponentValueQty
1)IR Proximity Sensor Module1
2)Arduino UnoRev 3, 8 KB1
3)Arduino Uno USB Cable
4)LED5mm, 3.5V
5)Breadboard
6)Laptop/PC
7)Jumper WiresMale/femaleAs per need
8)Resistor220 Ohms1

IR Proximity Sensor Pinout

Useful Steps

1) Connect the VCC and GND terminal of the IR proximity sensor module with the 5V & GND pin of the Arduino board.

2) Connect the OUT pin of the IR sensor with pin digital I/O pin 2 of the Arduino board.

3) Now join the +ve pin of the LED with pin 13 of the board & -ve with the GND of the Arduino.

4) Connect the Arduino Uno with a laptop and upload the code given below. After that, Power up & test the sensor.

Circuit Diagram

Source Code

int IR = 2;
int led = 13;

void setup() 
{
pinMode(IR,INPUT);
pinMode(led,OUTPUT);
}

void loop()
{
  digitalWrite(led,digitalRead(IR));
  delay(1000);
} 

Working Explanation

The working of this sensor is as follows. When an object is in the line of sight of the IR sensor module, the rays transmitted from the IR transmitter are reflected from the surface of the object and are collected by the IR receiver. The LED connected corresponding to this on the Arduino board starts to glow. In such a condition, the IR sensor gives a value of zero on the serial print() monitor.

When no object is in the path of the sensing element. The transmitted IR waves are not received by the IR receiver and the LED does not glow. In such a condition, the IR sensor gives a value of 1 on the serial print() monitor.

Applications

  • Used in small projects such as LFR (line following robots), TV remotes, color detection systems, etc.

See Also: Arduino DC Motor Control using L298N Motor Driver | How to setup WiFi on Raspberry Pi 3? | Ding Dong Sound Generator Circuit