How to Control Relay Using Arduino and Button

In this article, we are going to control two 12v lights with a 5v signal using a 12v relay and a button. This is a very simple project to show the operation of a control relay. This relay module requires 5v to operate. It has a double changeover switch that can switch 10amps AC at 250 volts and also, the 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 and also used in early computers to perform logical operations.

The Arduino relay module is designed for a wide range of microcontrollers like the Arduino board, AVR, PIC, ARM, with digital outputs. In this module, we have incorporated two relays.

Relay board

Control relay with arduino
relay module

Working of Relays

relay module
Working of relay

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

Relay Interface with Arduino

Material Required

  • Arduino
  • Relay Board 2 Channel
  • Pushbutton
  • 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
GNDSecond terminal
of both terminal
GND -ve-ve

To download the code click here. Then, upload it to your Arduino board. If you are new and don’t know how to do this, here are the tutorials to assist you- (Arduino Software Download and installation in 2 simple steps ) & (Arduino for beginners How to upload Arduino code)

If button-through random values are connected to a resistor as shown in the image below. Then, the Arduino itself will have inbuild pull up & pull-down resistance. You can start them while defining.

pinMode(2, INPUT_PULLUP);
relay interfacing with arduino

1 thought on “How to Control Relay Using Arduino and Button”

Leave a Comment