How to control relay using Arduino and button

Spread the love

In this article, we are going to control two 12v lights with a 5v signal using a 12v relay and button. This is a very simple project to show the operation of a control relay. This relay module needs 5 volts to operate. It has a double changeover switch that can switch 10amps AC at 250 volts as well as DC supply.

Control relay & Introduction to 2-channel module

A relay is defined as an electrically operated switch. Its main use is to control circuits by a low-power signal. The first relay was used in long distance telegraph circuits as amplifiers. Relays were also used in early computers to perform logical operations.

The Arduino relay module is designed for a wide range of microcontrollers. Such as the Arduino board, AVR, PIC, ARM, with digital outputs. This module we are using is incorporated 2 relays.

Relay board

Control relay with arduino
relay module

Working of Relay

relay module
Working of relay

When voltage is removed from the coil terminal the spring pulls the armature back into it’s ‘at rest’ position and breaks the circuit between the terminals. So by applying or removing power to the coil (the low current circuit) we switch the high current circuit on or off. This way we can control relay.

Relay interface with Arduino

Material Required

  • Arduino
  • Relay Board 2 Channel
  • Push Button
  • Breadboard
  • Jumpers

Relay wiring

Relay connection with arduino
Arduino connection with the relay
Arduino pin no.ButtonRelaySupplyLight
2One terminal
of button1
3 One terminal
of button2
10IN-1
11IN-2
N/O-1+ve
N/O-2+ve
COM 12v
COM12v
GNDSecond terminal
of both terminal
GND -ve-ve

Download code click here…. Upload it to your Arduino board. If you are new and don’t know how to do this here we have a tutorial on (Arduino Software Download and installation in 2 simple steps ) & (Arduino for beginners How to upload Arduino code)

If button-through random values connect a resistor as shown in the image below. Arduino itself have inbuild pull up & pull-down resistance you can initiate them during defining.

pinMode(2, INPUT_PULLUP);
pinMode(2, INPUT_PULLDOWN);
relay interfacing with arduino

One Comment

Add a Comment

Your email address will not be published. Required fields are marked *