Subscribe To Our List

We help electronics hobbyists to create projects related to Micro-controllers. Join our newsletter to get access to new projects first.
Email address
Secure and Spam free...

In this article, we are going to control an Arduino relay module. We will control two different devices using it. First we will control a simple LED then we will control a light bulb using it. The Arduino can control the devices which runs on up to 5V so if we want to control the devices which runs on more than 5V or the A.C devices then we will have to use a relay module through which we can control A.C as well as DC devices.

Relay Module

A relay is basically a switch which is operated by an electromagnet. The electromagnet requires a small voltage to get activated which we will give from the Arduino and once it is activated, it will pull the contact to make the high voltage circuit.

The relay module we are going to use is the SRD-05VDC-SL-C. It runs on 5V and we can control it with any micro-controller but we are going to use Arduino.

Pin out of 5V relay module

Arduino Relay module

Relay Module Pin out

The Arduino relay module has total of six pins: three on one side and three on other side.On the bottom side, there are three pins which are signal, 5V and ground. We will connect these pins with the Arduino. While on the other side, there are NC (Normally close), C (Common) and the NO (normally open) which are the output pins of the 5V relay. There, we will connect the output device.

Normally open state (NO) VS Normally closed state (NC)

The Arduino relay module can be used in two states which are

  1. Normally open state (NO)
  2. Normally closed state (NC)

Normally open (NO)

In the normally open state, the initial output of the relay will be low when it will be powered. In this state, the common and the normally open pins are used.

Normally closed state (NC)

In the normally closed state, the initial output of the relay will be high when it will be powered. In this state, the common and the normally close pins are used.

Controlling DC Devices using Arduino Relay Module

In the first part, we will control a led using the relay and in the second part we will control a high voltage device using the relay. Controlling a DC device is easy as compared to the AC device. For controlling the DC device, you do not require an external supply until you are controlling a small voltage device like LED which runs on up to 5V.

Circuit Diagram and Explanation

The connections for connecting the relay module with Arduino are very simple. In this example, we will connect the relay module with Arduino in the normally open state. So, connect the 5V and the ground of the Arduino with the 5V and the ground of the relay module. Then connect the signal pin of the relay module with the pin 12 of the Arduino.

On the other side of the relay module, we will use the common pin and the normally open pin because we are going to connect the relay in the normally open state. So, connect the pin 13 of Arduino to the common of relay module and the normally open (NO) of the relay module to the positive pin of the LED. Connect the other pin of LED to the ground of Arduino.

Control Led using Arduino relay module

Controlling LED using Arduino relay module

Code

int relay_pin = 8;
int led_pin = 13;

void setup(){ 
  pinMode(relay_pin,OUTPUT);
  pinMode(led_pin,OUTPUT);  
digitalWrite(led_pin,HIGH);}

void loop(){
  digitalWrite(relay_pin,HIGH);
  delay(5000);
  digitalWrite(relay_pin,LOW);
  delay(5000);
}

Controlling AC Device using Arduino Relay Module

For the control of AC device, you need to take the necessary precautions because the AC is dangerous and it can cause damage to you. So, to avoid any danger, follow the below tutorial correctly.

Circuit Diagram and Explanation

control ac device using arduino relay module

High Voltage Device with Arduino

For the control of AC device, we will require an external source which will power the AC source. So, connect the VCC, ground and signal to the 5V, ground and pin 8 of Arduino respectively. On the other end, connect one wire of the AC source to the one end of the bulb and the other wire to the common (C) of the relay. Then connect the normally open (NO) to the other end of the bulb.

Code

int relay_pin = 8;

void setup(){ 
  pinMode(relay_pin,OUTPUT);
}

void loop(){
  digitalWrite(relay_pin,HIGH);
  delay(5000);
  digitalWrite(relay_pin,LOW);
  delay(5000);
}

Videos


If you have any questions, feel free to ask us in the comment section.

JOIN OUR NEWSLETTER
We help electronics hobbyists to create projects related to Micro-controllers. Join our newsletter to get access to new projects first.
We hate spam. Your email address will not be sold or shared with anyone else.

Leave a Reply

Your email address will not be published.

Subscribe To Our List

We help electronics hobbyists to create projects related to Micro-controllers. Join our newsletter to get access to new projects first.
Email address
Secure and Spam free...
Skip to toolbar