How to Control a Relay With Arduino
by letsmake Electronics in Circuits > Arduino
984 Views, 0 Favorites, 0 Comments
How to Control a Relay With Arduino
Relays are the best way to control your appliances as they have less resistance between their contacts and can be used in many cases like to turn ON and OFF AC (Alternating Current) appliances like Lights, TV, Lamps and many other appliances. It is also very easy to control these relays with microcontrollers. To keep it simple I will be using Arduino as the microcontroller. So, without wasting anymore time let's get started.
Watch the Video
watch my video.
Choose Your Relay Module for Your Appliances.
Choosing your Relay module is very important. It depends on what appliances you are planning to control. This Relay I am using is REES52 single channel relay module which can do upto 10 Amps at 250 volts. Normally 10 Amps relay is suitable to turn ON and OFF most of the appliances. But, if you want to turn ON and OFF appliances like washer or electric water heater, choose a Relay with higher current rating like 20 amps.
Choose Your Arduino
You can use Arduino Nano, PRO mini or even Mega. But I will be using Arduino UNO for this project.
Use Male to Female Jumper Wires for Connections(OPTIONAL)
Use Male to Female jumper wires for the connections between Relay and the Arduino.(OPTIONAL)
Connections Between Relay Module and Arduino and Your Load
Connect the IN pin of the relay to the digital pin 6 of the Arduino, VCC to 5 volts, and ground to the ground pin of the Arduino.
The left one is the normally open terminal; the centre terminal is the common terminal and the right one is the normally closed terminal. To turn ON and OFF the load connect the positive wire of the Load to the Normally open terminal of the relay and the positive power wire to the common terminal.
Software Part. Code
Explanation of code
In the setup section, we declare the output pin as 6.
In the loop section, we tell the Arduino to turn on the relay. But the digital pin 6 is low. This is because this relay module is an active low relay module which means that this relay is pulled to ground to turn ON the relay and the other way around.
Then we delay for 4 seconds. If you want to increase the ON and OFF duration of your appliances increase the time in milliseconds in the bracket.
Then the relay turns off and we delay for 2 seconds.
This process continues until the power goes OFF.
Upload this code to the Arduino.
Downloads
RESULT : Turning ON and OFF of the Appliances With Arduino.
We can see that the appliances is controlled by the Arduino.
Feel free to checkout my channel for more awesome projects.