When working on Arduino projects, you’ll often need to control devices that require more power than the Arduino can handle. For example, household appliances like fans, lights, motors, and heaters typically run on high voltage , while the Arduino operates at just 5 volts. This means you cannot directly connect these high-power devices to your Arduino.
This is where a relay becomes extremely useful.
A relay module acts like a switch that can be turned ON or OFF by the Arduino. It allows the Arduino to safely control high-voltage or high-current devices by isolating them from the low-voltage Arduino circuit. Let's learn how to control a motor and RGB LED with a HL-52S relay module using Arduino.
What is a Relay and Why Use It with Arduino?A relay is an electrically operated switch that allows you to control a high-voltage or high-current circuit using a low-power signal—like that from an Arduino. When the relay is energized, it closes (or opens) a mechanical switch that can handle significantly more voltage and current than the Arduino can. By interfacing a relay module with an Arduino, you can safely and efficiently control high-power devices.
Interfacing the HL-52S 5V Relay Module with ArduinoOne of the most popular relay modules is the HL-52S 5V module. It comes in single, dual, and four-channel versions. In this tutorial, we’ll focus on using the four-channel version of the HL-52S relay module.
This module is designed to work directly with 5V logic, making it fully compatible with Arduino Uno and other 5V microcontrollers.
Overview: 5V Four-Channel HL-52S Relay ModuleThe 4-channel relay module contains four individual relays. This means you can control four separate devices using one module.
- VCC: Supplies power to the module. This pin should be connected to the 5V output of the Arduino.
- GND: This is the ground pin and must be connected to the Arduino’s GND.
- IN1 to IN4: These are the input pins used to control each relay individually. Sending a HIGH or LOW signal to these pins will turn the corresponding relay ON or OFF.
- NO (Normally Open): This terminal is open (disconnected) when the relay is inactive. When the relay is energized, it connects to the COM pin, allowing current to flow.
- NC (Normally Closed): This terminal is connected to the COM pin by default when the relay is OFF. It disconnects when the relay is turned ON.
- COM (Common): This is the central terminal that connects either to the NO or NC pin depending on the relay’s state. It acts as the switching point between the other two terminals.
Here we’ll control a DC motor and a multi-colored RGB LED using the relay module:
First, the motor will be turned ON.
Then, each LED color (Red, Blue, and Green) will be activated one after another by connecting their anode pins to the power supply through the relay.
This will make the LED glow in different colors.
Finally, the motor will be switched OFF, and the LED will turn OFF as well.
This example demonstrates how relays can be used to sequentially control multiple devices in an automated manner using Arduino.
The Output of Code
To learn more checkout: Interfacing 5V 4-Channel Relay Module with Arduino
Comments