This tutorial is part of: Điều khiển rơle bằng Arduino
Đây là các video được nhóm lại, tất cả đều liên quan đến môn chạy tiếp sức. Các liên kết đến các video khác nằm bên dưới bài viết này.
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).

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


-
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

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
This tutorial is part of: Điều khiển rơle bằng Arduino
- Arduino Code and Video for a Dual-Channel 5V Relay
- TTP224 4-Channel Touch Sensor to Turn AC/DC Loads with Relay
- Sử dụng mô-đun rơ-le 5V (Kích hoạt Thấp) với Arduino
- Using a MAX6675 K-Type Thermocouple with Relay and Display
- Using a Reed Switch to Control a Relay and AC/DC Loads with an Arduino
- Using a TTP223B touch module and relay to control AC/DC loads with an Arduino
- Using an Arduino push button to switch a relay and AC bulb
/*
* This is the Arduino code for Dual Channel 5V Relay
* to control turning ON or OFF AC or DC loads
* Watch the video https://youtu.be/58XWVDnB7Ss
*
* Written by Ahmad Nejrabi for Robojax Video
* Date: December 26, 2017, in Ajax, Ontario, Canada
* Permission granted to share this code given that this
* note is kept with the code.
* Disclaimer: this code is "AS IS" and for educational purposes only.
*
*/
void setup() {
pinMode(7, OUTPUT);// connected to S terminal of Relay
}
void loop() {
digitalWrite(7,HIGH);// turn relay ON
delay(3000);// keep it ON for 3 seconds
digitalWrite(7, LOW);// turn relay OFF
delay(5000);// keep it OFF for 5 seconds
}
Nghĩ bạn có thể cần
-
Amazon1 Channel 5V Relay Moduleamzn.to
-
AliExpressPurchase 5v 12v 1 2 4 6 8 channel channel relay moduls.click.aliexpress.com
Tài nguyên & tài liệu tham khảo
Chưa có tài nguyên nào.
Tập tin📁
Không có tệp nào khả dụng.