Controlling a 5V Relay Using Arduino to cotrol AC or DC load like bulb or motor

Controlling a 5V Relay Using Arduino to cotrol AC or DC load like bulb or motor

This tutorial demonstrates how to use a 5V relay module with Arduino to control high-voltage devices such as lights, fans, or other appliances. The relay used in this lesson is high-trigger, meaning it activates when the signal pin receives a high-level voltage (5V).

5V HIGH-level trigger relay module

Relay modules are essential in home automation and industrial control systems, allowing you to safely interface microcontrollers with AC-powered devices.

The Arduino code and wiring diagram are available below this article.

What is a High-Trigger Relay?

A relay is an electromechanical switch controlled electrically. The high-trigger version activates when the input signal pin is brought HIGH (typically 5V). It contains:

  • An electromagnetic coil for switching

  • A normally open (NO) and normally closed (NC) contact

    Relay wiring when load is OFF
    Relay wiring when load is ON
  • Signal, VCC, and GND pins

This module allows Arduino to control devices that operate at a higher voltage than the board can handle directly.

 

Wiring the Relay Module

Arduino wiring for AC bulb with HIGH-level trigger relay
Arduino wiring for AC bulb with HIGH-level trigger relay

To safely use the relay with Arduino, wire it as follows:

  • VCC (middle pin) -5V on Arduino

  • GND -GND on Arduino

  • IN (Signal pin) -Digital Pin 2 on Arduino

  • Relay Output terminals -Connect one of the terminals in series with a light bulb, fan, or any other AC/DC load.

 Code Overview

Here’s the basic Arduino code used in this lesson:

cppCopyEditvoid setup() {
  pinMode(2, OUTPUT);     // Set pin 2 as output
}

void loop() {
  digitalWrite(2, HIGH);  // Turn relay ON
  delay(1000);            // Wait 1 second
  digitalWrite(2, LOW);   // Turn relay OFF
  delay(1000);            // Wait 1 second
}

  • The relay is turned ON when digital pin 2 is set to HIGH.

  • The relay is turned OFF when pin 2 is set to LOW.

  • The cycle repeats every 1 second.

This setup is commonly used to automate home lighting or power control based on sensors or time schedules.

 

Chapters From the Video

  • 00:00 – Relay Explained

  • 03:33 – Wiring Explained

  • 04:42 – Code Explained

  • 06:10 – Demonstration

 

Изображения

Relay wiring when load is OFF
Relay wiring when load is OFF
Relay wiring when load is ON
Relay wiring when load is ON
5V relay module
5V relay module
5V HIGH-level trigger relay module
5V HIGH-level trigger relay module
5V HIGH-level trigger relay module
5V HIGH-level trigger relay module
5V HIGH-level trigger relay module - back
5V HIGH-level trigger relay module - back
Arduino wiring for AC bulb with HIGH-level trigger relay
Arduino wiring for AC bulb with HIGH-level trigger relay
45-This is the Arduino code for a 5V relay
Язык: C++
Скопировано!

Вещи, которые могут вам понадобиться

Ресурсы и ссылки

Ресурсов пока нет.

Файлы📁

Нет доступных файлов.