How to use a Relay with Arduino

In this article you will learn how to use a relay with Arduino. Arduino relay module is used to control high voltage appliances with Arduino.

Before getting started you must know how relay works.

Relay is an electromagnetic device which is used to isolate two circuits electrically and connect them magnetically. They are very useful devices and allow one circuit to switch another one while they are completely separate. They are often used to interface an electronic circuit (working at a low voltage) to an electrical circuit which works at very high voltage. For example, a relay can make a 5V DC battery circuit to switch a 230V AC mains circuit. A relay switch can be divided into two parts: input and output. The input section has a coil which generates magnetic field when a small voltage from an electronic circuit is applied to it. This voltage is called the operating voltage. In a basic relay there are three contactors: normally open (NO), normally closed (NC) and common (COM).

relay working

Watch Video Explanation

Relay Module Pin Configuration


relay module pin configuration

You can get a Relay Module here [ Amazon India / Banggood / Gearbest ]

Arduino Relay Wiring

arduino relay circuit


Arduino Relay Code

// Arduino Code for Relay Module
int pin=2;
void setup() {

void loop() {
  digitalWrite(pin,HIGH);  // Turn ON relay
  delay(10000);            // Delay  of 10 Seconds
  digitalWrite(pin,LOW);   // Turn OFF relay
  delay(10000);            // Delay  of 10 Seconds


If you have any queries feel free to comment below.

Leave a Reply