How to Use Arduino Relay 5V Module to Control 220V Lights
How to Use Arduino Relay 5V Module to Control 220V Lights
This tutorial explains how to use a 5V Relay Module with Arduino UNO to control 220V electrical devices like lights, fans, or other appliances. This module supports both High and Low Trigger modes at 250V/10A.
Required Components
- Arduino UNO R3 with USB cable
- 5V Relay Module 1 Channel (High/Low Trigger)
- Breadboard 830 points
- Jumper wires (Male-Male, Male-Female)
- LED Bulb E27 with lamp holder
- AC Power cord with plug
- 9V 2A Adapter (for relay power supply)
Wiring Instructions
1. Connect Arduino to Relay Module
| Arduino | Relay Module |
|---|---|
| 5V | DC+ |
| GND | DC- |
| Pin 2 | IN |
2. Connect 220V Circuit
- COM terminal connects to live AC wire
- NO terminal connects to the device you want to control (e.g., light bulb)
- Device connects back to AC neutral wire
Important: Be careful when working with 220V. Always turn off the main switch before connecting wires.
Arduino Code - High Trigger Mode
In this mode, set the Jumper to H position. The relay activates when Arduino sends a HIGH signal.
const int RELAY_PIN = 2; // Pin connected to IN pin of Relay
void setup() {
pinMode(RELAY_PIN, OUTPUT);
// Start with relay off (circuit not connected)
digitalWrite(RELAY_PIN, LOW);
}
void loop() {
// Turn on light (relay activates)
digitalWrite(RELAY_PIN, HIGH);
delay(10000); // Light on for 10 seconds
// Turn off light (relay deactivates)
digitalWrite(RELAY_PIN, LOW);
delay(2000); // Light off for 2 seconds
}
Arduino Code - Low Trigger Mode
In this mode, set the Jumper to L position. The relay activates when Arduino sends a LOW signal.
const int RELAY_PIN = 2;
void setup() {
pinMode(RELAY_PIN, OUTPUT);
// Start with relay off (send HIGH because it's Low Trigger)
digitalWrite(RELAY_PIN, HIGH);
}
void loop() {
// Turn on light (send LOW to trigger relay)
digitalWrite(RELAY_PIN, LOW);
delay(2000); // Light on for 2 seconds
// Turn off light (send HIGH to stop triggering)
digitalWrite(RELAY_PIN, HIGH);
delay(10000); // Light off for 10 seconds
}
How to Upload Code
- Open Arduino IDE and paste the code above
- Go to Tools > Port and select the port connected to your board
- Go to Tools > Board and select Arduino UNO
- Click Upload button and wait for “Done uploading” message
Difference Between NC and NO
- NC (Normally Closed) - Circuit is connected when relay is inactive
- NO (Normally Open) - Circuit is disconnected when relay is inactive, and connects when relay activates
For general use like controlling lights, connect to NO terminal because you want the light off by default when not commanded.
Summary
| Mode | Jumper | Trigger Signal | Operation |
|---|---|---|---|
| High Trigger | H | HIGH (5V) | Relay activates on HIGH |
| Low Trigger | L | LOW (0V) | Relay activates on LOW |
Reference Video
อยากทำโปรเจคแบบนี้?
รับทำโปรเจค Arduino / IoT จบงานไว ส่งงานครบ พร้อมสอน
If you need Arduino project service or urgent IoT development, see full service details on the home page
จ้างทำโปรเจคเลย