DETAILED EXPLANATION ON HOW TO USE RELAY MODULE WITH ARDUINO UNO IN CONTROLLING APPLIANCES

avatar

arduino with relay_bb.png

Relay is an electromechanical and electromagnetic switch that is widely utilized in controlling appliances. As it makes it easy to use small current applied to its coil terminals to control larger appliances.

In this post, I would be explaining in detail how to use a relay with Arduino Uno microcontroller in controlling or switching on or off appliances which as an instance the appliance would be a light bulb.


HARDWARE COMPONENTS


  1. Arduino Uno
  2. 5v Relay Module
  3. Light Bulb
  4. Power Supply Source
  5. Connecting Wires

SOFTWARE COMPONENTS


  1. Arduino IDE
  2. C / C++ Programming Language
  3. Fritzing

The Arduino Uno Microcontroller


arduino.png

Arduino Uno is a very common microcontroller is highly utilized in lots of projects or devices where the need of a microcontroller is need or required. All codes and instructions on how a device is expected or programed to perform are been uploaded to the arduino uno, then all other supporting components or circuitory communicates with the microcontroller in sharing resources.


A Relay Module


relay.png

A typical relay as 5 terminals which consists of 2 coil terminals, the common terminal, the normally closed terminal and normally open terminal. But on the other hand a relay module makes it easy to use the relay with microcontroller like the arduino uno which as 6 terminals, which are the Vcc, GND, Source, NC (Normally Closed), NO (Normally Open) and the C (Common) terminals as shown in the image above. With the relay module the source pin or terminal is been connected to any digital pin of the arduino uno microcontroller while the Vcc and GND goes straight to the Relays are majorly used as switches in lots of devices and equipment due to their ability to control larger appliances by applying a small voltage to their coil terminal.

By default the normally closed terminal and the common terminal of the relay module are connected together internally but when the relay is been energized the common switches from normally closed to the normally open terminal thereby completing or connecting the broken connections together. Allowing the voltage coming from the power supply source to connect with the positive terminal of the appliance and for this case its the bulb and thereby making it come on.


The Bulb



bulb.png

The buld is used in the case to represent an appliance which is intended to be controlled through a relay from a microcontroller like the arduino uno.


THE CODE


// constants won't change
const int RELAY_PIN = 3;  // the Arduino pin, which connects to the IN pin of relay

// the setup function runs once when you press reset or power the board
void setup() {
  // initialize digital pin as an output.
  pinMode(RELAY_PIN, OUTPUT);
}

// the loop function runs over and over again forever
void loop() {
  digitalWrite(RELAY_PIN, HIGH);
  delay(500);
  digitalWrite(RELAY_PIN, LOW);
  delay(500);
}

Thanks for reading. Kindly support this post by reblogging, upvoting, and commenting, it would be highly appreciated.

Frizting circuit design software was used by me in design the images and circuit diagrams in this post

Posted with STEMGeeks



0
0
0.000
1 comments
avatar

Nice post @lcrypt. Relays are indeed highly utilized in devices and electronics products like the voltage stabilizer for switching between different voltage levels as the input voltage varies and more.

Weldone 👍.

0
0
0.000