top of page

interfacing ir sensor with arduino uno

Updated: Feb 12

In this article, you will learn to interface an #IRsensor and a #relaymodule with Arduino.

Hardware Components - Interfacing IR sensor


1. Arduino Uno:

It is an open-source microcontroller board that can be programmed according to user requirements. #ArduinoUno board is used for interfacing the input-output elements to construct a project. | Interfacing IR sensor |


ir sensor,ir receiver,ir sensor working,ir remote,ir sensor module ,ir sensor pinout,ir module
Arduino Uno

2. Breadboard:

A breadboard is a simple rectangular board that has many holes shorted in a specific manner. It is the construction base for implementing electronic projects. The holes are used to connect circuit components like ICs, capacitors, potentiometers.


Breadboard
Breadboard

3. IR sensor:

IR sensor is an electronic device that senses the IR radiations in its surroundings. The IR sensor used here is an active IR sensor that emits IR radiation from the transmitter diode and receives the reflected rays from the target object through a receiver.


IR sensor
IR sensor

4. LED:

Light Emitting Diode (LED) is a semiconductor device that emits light when the current flows through it. The color of the light emitted by the LED depends on the bandgap the electrons need to cross to recombine with the holes in the semiconductor. In this project, an IR sensor is used to indicate the detection of the object by an IR sensor.


LED
LED

5. Resistor-220Ω:

The resistor is a passive electronic component that offers resistance to the current flowing through it. Here it is used to reduce the current flowing through the LED. A 220Ω resistor is used in this project.


220Ω resistor
220Ω resistor

6. Relay Module:

A relay module is an electrical switch that can be opened or closed using an electromagnet. It acts as a circuit breaker and detects the faulty current in the circuit. To understand the working of a relay module click here: Electrical Relay



Relay module
Relay module

7. Jumper wires:

Jumper wires have connectors and pins that are used to connect different components on a breadboard.


Jumper wires
Jumper wires

Circuit Connections:


1. Interfacing IR sensor with Arduino:


Circuit for interfacing IR sensor with Arduino
Circuit for interfacing IR sensor with Arduino
  1. Connect the Vcc pin of the IR sensor to the Vcc of the Arduino via a breadboard.

  2. Connect the ground pin of the IR sensor to the ground of the Arduino.

  3. Connect the output pin of the IR sensor to D2 of the Arduino.

  4. Connect cathode lead of the LED to the ground rail of the breadboard.

  5. Connect the anode lead of the LED to one of the arms of the 220Ω resistor.

  6. Connect another arm of the resistor to D3 of the Arduino.


2. Interfacing IR sensor and relay module with Arduino:



Circuit for Interfacing IR sensor and relay module with Arduino
Circuit for Interfacing IR sensor and relay module with Arduino
  1. Connect the Vcc pin of the IR sensor to the Vcc of the Arduino via a breadboard.

  2. Connect the ground pin of the IR sensor to the ground of the Arduino.

  3. Connect the output pin of the IR sensor to D2 of the Arduino.

  4. Connect the Vcc of the relay module to the Vcc rail of the breadboard and connect the ground in of the relay module to the ground rail of the breadboard.

  5. Connect the signal pin of the relay module to D3 of the Arduino.

  6. Connect the common terminal of the relay module to the positive of the external power supply.

  7. Connect the cathode of the LED to the negative terminal of the external power supply.

  8. Connect the anode of the LEd to one of the arms of the resistor. The other arm of the resistor is connected to the normally open terminal of the relay module.

Code:



  • Define the IR pin and the LED pin concerning the Arduino connections.

  • Define a boolean variable for the IR value and set it to low.

  • In the void.setup() declare the pin modes of the IR and the LED. Also, start the serial monitor output with 9600 as the baud rate.

  • Store the IR sensor output in the ir_val using the digitalRead() function.

  • Using the if-else condition, set the LED to low for a high IR output, low otherwise. Print the LED's condition using the digitalWrite() function.

Working:

The IR sensor is used to detect the presence of an object in its range. If there is an object in its vicinity, the IR output reads low and, the LED glows. The IR output reads high if there is no object in its range and the LED is turned OFF. A relay switch can be employed to control the LED following the IR sensor output.


The following picture shows the circuit connections. The LED bulb is in the OFF state. The LED bulb will be in the ON state when the IR sensor reads low output.


OFF state of the LED bulb
OFF state of the LED bulb

Check the Project Working video here - Interfacing IR sensor and Relay with Arduino

Video By - Maninder Kumar Jha



Written by-

Name- Nagashree R Nadig


See also-


ir sensor,ir receiver,ir sensor working,ir remote,ir sensor module ,ir sensor pinout,ir module


ir sensor,ir receiver,ir sensor working,ir remote,ir sensor module ,ir sensor pinout,ir module


Follow us -


Please do follow us i.e #learnelectronicsindia to get daily updates about new blogs, videos, courses, quizzes, and contests.



Want us to help you with the projects, write your inquiry here - Order Projects


Check out our Free Arduino Projects Playlist - Arduino Projects

Check out our Free Raspberry Pi Projects Playlist - Raspberry Pi Projects

Check out our Free TinkerCAD Projects Playlist - TinkerCAD Projects

Check out our Free IoT Projects Playlist - IoT Projects

Check out our Free Home Automation Projects Playlist - Home Automation Projects

Check out our Free NodeMCu Projects Playlist - NodeMCu Projects

Related Posts

See All

6 Comments


Impressive tutorial! Your step-by-step guide on interfacing an IR sensor with Arduino Uno made it a breeze for me to understand. Thanks for simplifying the process!

Like

Daipayan Maitra
Daipayan Maitra
Aug 10, 2023

Brilliant blog! Your guide on utilizing an infrared sensor Arduino was exactly what I needed. The step-by-step instructions on setting up the IR sensor Arduino project were clear and concise. Thank you for simplifying the process and shedding light on this fascinating technology!

Like

Informative and concise! LearnElectronics India always delivers quality content.

Like

Anushka Gupta
Anushka Gupta
Jul 19, 2023

This blog is an absolute gem! I've been searching for a clear and concise tutorial on interfacing an IR sensor with Arduino Uno, and Learn Electronics India delivered it perfectly. The step-by-step instructions and well-explained code examples made it so easy for me to understand and implement. Thank you for sharing such valuable knowledge.

Like

PALAK SHARMA
PALAK SHARMA
Jun 22, 2023

Kudos for the informative blog! Your insights on integrating an IR sensor with Arduino were insightful. As a beginner in this field, I found your explanations on infrared sensor Arduino projects to be clear and easy to follow. Keep up the good work!

Like