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 |
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.
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.
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.
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.
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
7. Jumper wires:
Jumper wires have connectors and pins that are used to connect different components on a breadboard.
Circuit Connections:
1. Interfacing IR sensor with Arduino:
Connect the Vcc pin of the IR sensor to the Vcc of the Arduino via a breadboard.
Connect the ground pin of the IR sensor to the ground of the Arduino.
Connect the output pin of the IR sensor to D2 of the Arduino.
Connect cathode lead of the LED to the ground rail of the breadboard.
Connect the anode lead of the LED to one of the arms of the 220Ω resistor.
Connect another arm of the resistor to D3 of the Arduino.
2. Interfacing IR sensor and relay module with Arduino:
Connect the Vcc pin of the IR sensor to the Vcc of the Arduino via a breadboard.
Connect the ground pin of the IR sensor to the ground of the Arduino.
Connect the output pin of the IR sensor to D2 of the Arduino.
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.
Connect the signal pin of the relay module to D3 of the Arduino.
Connect the common terminal of the relay module to the positive of the external power supply.
Connect the cathode of the LED to the negative terminal of the external power supply.
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.
Check the Project Working video here - Interfacing IR sensor and Relay with Arduino
Video By - Maninder Kumar Jha
Written by-
Name- Nagashree R Nadig
Portfolio Link- https://www.learnelectronicsindia.com/team/nagashree-r-nadig
See also-
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
Order Electronics Projects
Want us to guide you through your project or make the project for you? Click on the button below or reach out to us via Call/WhatsApp at (+91) - 7600948607
You can -
Order Basic Electronics Projects
Order Embedded Systems Projects
Order IoT Projects
Order FPGA Projects
Order VLSI Projects
Order Image Processing Projects
Order Matlab Projects
Order TinkerCAD Projects
Order Proteus Projects
Click on the button below to fill out the project inquiry form -
Follow us -
Please do follow us i.e. #learnelectronicsindia to get daily updates about new blogs, videos, courses, products, offers, competitions, quizzes, and Internship Opportunities.
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!
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!
Informative and concise! LearnElectronics India always delivers quality content.
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.
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!