This tutorial is part of: 아두이노를 이용한 릴레이 제어
이 페이지는 릴레이와 관련된 모든 동영상을 모아놓은 곳입니다. 다른 동영상 링크는 이 글 아래에 있습니다.
아두이노 코드 및 듀얼 채널 5V 릴레이용 비디오
이 튜토리얼에서는 Arduino와 듀얼 채널 5V 릴레이를 사용하여 AC 및 DC 부하를 제어하는 방법을 배웁니다. 릴레이를 사용하면 AC 전구와 DC 모터와 같은 두 개의 서로 다른 부하를 전환할 수 있어 다양한 응용 분야에 유연성을 제공합니다. 이 가이드가 끝나면 자신만의 릴레이 시스템을 설정하고 간단한 Arduino 코드를 통해 제어할 수 있게 됩니다.

전체 과정에서 필요한 부품, 배선 지침, 그리고 릴레이를 제어하는 데 사용되는 Arduino 코드에 대한 설명을 다룰 것입니다. 이 프로젝트는 전자 및 자동화의 세계를 탐구하려는 초보자에게 완벽합니다. 시각적 가이드를 위해 관련 비디오(비디오 00:00)를 시청하세요.
하드웨어 설명
이 프로젝트의 주요 구성 요소는 듀얼 채널 5V 릴레이입니다. 이 릴레이는 별도의 부하를 제어할 수 있는 두 개의 독립적인 스위치로 구성됩니다. 각 릴레이에는 세 개의 접점이 있습니다: Normally Closed(NC), Normally Open(NO), 그리고 Common(COM). 릴레이가 활성화되면 NO 접점이 연결되어 부하를 통해 전류가 흐를 수 있습니다.
다른 필수 구성 요소로는 디지털 핀을 통해 릴레이를 제어할 Arduino 보드가 있습니다. 릴레이 모듈에는 릴레이가 활성화될 때 켜지는 표시 LED도 있습니다. 또한 릴레이는 광학적으로 절연되어 제어 회로와 부하 회로를 분리하여 안전성을 제공합니다.
데이터시트 세부 정보
| 제조업체 | Songle |
|---|---|
| 부품 번호 | SRD-05VDC-SL-C |
| 로직/IO 전압 | 5 V |
| 공급 전압 | 5 V |
| 출력 전류(채널당) | 10 A |
| 피크 전류(채널당) | 10 A |
| PWM 주파수 안내 | 해당 없음 |
| 입력 로직 임계값 | 최소 2.5 V |
| 전압 강하 / RDS(on) / 포화 | 80 mΩ |
| 열 제한 | 70 °C |
| 패키지 | 모듈 |
| 참고 사항 / 변형 | 광학 절연 |
- AC 부하를 연결할 때 적절한 절연을 보장하세요.
- 높은 부하 시 안전을 위해 적절한 퓨즈를 사용하세요.
- 릴레이 모듈을 습기로부터 멀리 유지하세요.
- 고전력 응용 분야에서는 방열판을 고려하세요.
- 손상을 방지하기 위해 전원을 켜기 전에 배선을 확인하세요.
- 필요한 경우 고전류 장치에 별도의 전원 공급 장치를 사용하세요.
배선 지침

듀얼 채널 릴레이를 Arduino에 배선하려면 릴레이 모듈의 VCC 핀을 Arduino의 5V 핀에 연결하는 것으로 시작하세요. 릴레이의 GND 핀을 Arduino의 GND 핀에 연결하세요. 이렇게 하면 릴레이 모듈에 전원이 공급됩니다.
다음으로 제어 핀을 연결하세요: 릴레이의 IN1 핀을 Arduino의 디지털 핀 7에 연결하고 IN2 핀을 디지털 핀 8에 연결하세요. 이 설정을 통해 두 릴레이를 독립적으로 제어할 수 있습니다. 마지막으로 AC 또는 DC 부하를 필요에 따라 릴레이 접점에 연결하되, AC 전압을 다룰 때는 적절한 안전 예방 조치를 따르세요.
코드 예제 및 설명
Arduino 코드에서 직렬 통신을 초기화하고 릴레이 제어 핀의 핀 모드를 설정하는 것으로 시작합니다. 변수 relay1Pin과 relay2Pin은 각 릴레이에 연결된 핀을 나타내도록 정의됩니다. 그런 다음 루프에서 이 핀들의 출력 상태가 전환됩니다.
const int relay1Pin = 7; // 릴레이 1용 핀 정의
const int relay2Pin = 8; // 릴레이 2용 핀 정의
void setup() {
Serial.begin(9600); // 정보를 표시하기 위해 시리얼 모니터 설정
pinMode(relay1Pin, OUTPUT); // 릴레이 1에 연결됨
pinMode(relay2Pin, OUTPUT); // 릴레이 2에 연결됨
}
이 발췌문은 디버그 정보를 출력하기 위해 시리얼 모니터를 초기화하고 릴레이 제어 핀을 출력으로 설정합니다. 이는 릴레이를 필요에 따라 켜고 끌 수 있도록 하는 데 중요합니다.
void loop() {
digitalWrite(relay2Pin, LOW); // 릴레이 2 끄기
Serial.print("Pin 8 LOW");
digitalWrite(relay1Pin, HIGH); // 릴레이 1 켜기
Serial.println(" Pin 7 HIGH");
delay(3000); // 릴레이 2 OFF 및 릴레이 1 ON 상태를 3초 동안 유지
digitalWrite(relay1Pin, LOW); // 릴레이 1 끄기
digitalWrite(relay2Pin, HIGH); // 릴레이 2 켜기
Serial.print("Pin 7 LOW");
Serial.println(" Pin 8 HIGH");
delay(3000); // 릴레이 1 OFF 및 릴레이 2 ON 상태를 3초 동안 유지
}
이 코드는 3초마다 릴레이를 전환하여 하나를 켜는 동안 다른 하나를 끕니다. 시리얼 모니터는 핀의 상태를 출력하여 디버깅과 릴레이 작동 이해에 도움이 됩니다.
시연 / 기대 효과
설정이 완료되면 릴레이가 3초마다 연결된 부하 사이를 전환하는 것을 볼 수 있습니다. 릴레이는 연결된 AC 전구 또는 DC 모터를 번갈아 활성화합니다. AC 부하를 다룰 때는 주의하세요. 부적절한 취급은 위험한 상황을 초래할 수 있습니다(비디오 12:34).
비디오 타임스탬프
- 00:00 - 듀얼 채널 릴레이 소개
- 04:15 - 배선 지침
- 08:30 - 코드 설명
- 10:45 - 릴레이 시연
This tutorial is part of: 아두이노를 이용한 릴레이 제어
/*
* This is the Arduino code for Dual Channel 5V Relay
* to control turning ON or OFF AC or DC loads. You can control 2 different loads such as bulbs, or a heater, or other machines.
Watch the video instruction for this code: https://youtu.be/EclIomn_3dI
* *
* Written by Ahmad Shamshiri 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.
Get this code and other Arduino codes from Robojax.com
Learn Arduino step by step in a structured course with all materials, wiring diagrams and libraries
all in one place. Purchase my course on Udemy.com: http://robojax.com/L/?id=62
If you found this tutorial helpful, please support me so I can continue creating
content like this. You can support me on Patreon: http://robojax.com/L/?id=63
or make a donation using PayPal: http://robojax.com/L/?id=64
*
* This code is "AS IS" without warranty or liability. Free to be used as long as you keep this note intact.*
* This code has been downloaded from Robojax.com
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
void setup() {
Serial.begin(9600);// setup Serial Monitor to display information
pinMode(7, OUTPUT);// connected to Relay 1
pinMode(8, OUTPUT);// connected to Relay 2
}
void loop() {
digitalWrite(8, LOW); // turn relay 2 OFF
Serial.print("Pin 8 LOW");
digitalWrite(7,HIGH);// turn relay 1 ON
Serial.println(" Pin 7 HIGH");
delay(3000);// keep in relay 2 OFF and relay 1 On for 3 seconds
digitalWrite(7, LOW);// turn relay 1 OFF
digitalWrite(8,HIGH);// turn relay 2 ON
Serial.print("Pin 7 LOW");
Serial.println(" Pin 8 HIGH");
delay(3000);// keep in relay 1 OFF and relay 2 On for 3 seconds
}
/*
* This is the Arduino code for a dual-channel 5V relay
* to control turning ON or OFF AC or DC loads. You can control 2 different loads such as bulbs, a heater, or other machines.
Watch the video instruction for this code: https://youtu.be/EclIomn_3dI
* *
* Written by Ahmad Shamshiri 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.
Get this code and other Arduino codes from Robojax.com
Learn Arduino step by step in a structured course with all materials, wiring diagrams, and libraries
all in one place. Purchase my course on Udemy.com: http://robojax.com/L/?id=62
If you find this tutorial helpful, please support me so I can continue creating
content like this. You can support me on Patreon: http://robojax.com/L/?id=63
or make a donation using PayPal: http://robojax.com/L/?id=64
*
* This code is "AS IS" without warranty or liability. Free to be used as long as you keep this note intact.
* This code has been downloaded from Robojax.com
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
const int relay1Pin =7;// define pin for relay 1
const int relay2Pin =8; // define pin for relay 2
void setup() {
Serial.begin(9600);// setup Serial Monitor to display information
pinMode(relay1Pin, OUTPUT);// connected to Relay 1
pinMode(relay2Pin, OUTPUT);// connected to Relay 2
}
void loop() {
digitalWrite(relay2Pin, LOW); // turn relay 2 OFF
Serial.print("Pin 8 LOW");
digitalWrite(relay1Pin,HIGH);// turn relay 1 ON
Serial.println(" Pin 7 HIGH");
delay(3000);// keep in relay 2 OFF and relay 1 On for 3 seconds
digitalWrite(relay1Pin, LOW);// turn relay 1 OFF
digitalWrite(relay2Pin,HIGH);// turn relay 2 ON
Serial.print("Pin 7 LOW");
Serial.println(" Pin 8 HIGH");
delay(3000);// keep in relay 1 OFF and relay 2 On for 3 seconds
}
필요할 수 있는 것들
-
알리익스프레스Purchase 5v 12v 1 2 4 6 8 channel channel relay moduls.click.aliexpress.com
자원 및 참고자료
아직 자원이 없습니다.
파일📁
파일이 없습니다.