Controlling AC light using Arduino UNO with Relay module

BATHULA PRAVEEN (BP)
0



This experiment shows how to control mains voltage with the Arduino using a relay module. We make a brief introduction to the relay module and build a simple circuit with the Arduino. The example we’ll build shows how to control a relay module with an Arduino.

Relay Module

A relay is an electrically operated switch that can be turned on or off, letting the current go through or not, and can be controlled with low voltages, like the 5V provided by the Arduino pins.

 


This relay module has two channels (those blue cubes). There are other models with one, four and eight channels. This module should be powered with 5V, which is appropriate to use with an Arduino. There are other relay modules that are powered using 3.3V, which is ideal for ESP32, ESP8266, and other microcontrollers.

Relay Pinout

The following figure shows the relay module pinout.

 


The six pins on the left side of the relay module connect high voltage, and the pins on the right side connect the component that requires low voltage—the Arduino pins.

Mains voltage connections

The high-voltage side has two connectors, each with three sockets: common (COM), normally closed (NC), and normally open (NO).

COM: common pin

NC (Normally Closed): the normally closed configuration is used when you want the relay to be closed by default, meaning the current is flowing unless you send a signal from the Arduino to the relay module to open the circuit and stop the current.

NO (Normally Open): the normally open configuration works the other way around: the relay is always open, so the circuit is broken unless you send a signal from the Arduino to close the circuit.


If you just want to light up a lamp occasionally, it is better to use a normally-open circuit configuration.

The connections between the relay module and the Arduino are really simple:

GND: goes to ground

IN1: controls the first relay (it will be connected to an Arduino digital pin)

IN2: controls the second relay (it should be connected to an Arduino digital pin if you are using this second relay. Otherwise, you don’t need to connect it)

VCC: goes to 5V

 


PROGRAM::

int relay = 8;

void setup() {

  // Pin for relay module set as output

  pinMode(relay, OUTPUT);

  digitalWrite(relay, HIGH);

}

void loop() {

    digitalWrite(relay, HIGH);

    Serial.println("OFF");

    delay(50);

  relayState = HIGH;  

  Serial.println("ON"); }}


Post a Comment

0Comments

Post a Comment (0)