กลับหน้าหลัก
views
How to Use Arduino Relay 5V Module to Control 220V Lights
Last updated on

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.

Diagram showing 5V Relay Module with labeled components including VCC, GND, IN, COM, NC, NO pins and Jumper position for mode selection

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

ArduinoRelay Module
5VDC+
GNDDC-
Pin 2IN

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
Complete circuit diagram showing Arduino, Relay Module, light bulb and 220V household power connected clearly

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

  1. Open Arduino IDE and paste the code above
  2. Go to Tools > Port and select the port connected to your board
  3. Go to Tools > Board and select Arduino UNO
  4. Click Upload button and wait for “Done uploading” message
Screenshot of Arduino IDE showing successful code upload with Done uploading message displayed

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

ModeJumperTrigger SignalOperation
High TriggerHHIGH (5V)Relay activates on HIGH
Low TriggerLLOW (0V)Relay activates on LOW

Reference Video

https://www.youtube.com/embed/8YzJBOYbmtA

อยากทำโปรเจคแบบนี้?

รับทำโปรเจค Arduino / IoT จบงานไว ส่งงานครบ พร้อมสอน

If you need Arduino project service or urgent IoT development, see full service details on the home page

จ้างทำโปรเจคเลย

ความคิดเห็น

Verified user reviews

รีวิวและความคิดเห็นจากผู้ใช้จริง

ล็อกอินด้วยบัญชีบนเว็บนี้แล้วให้คะแนนหรือคอมเมนต์ได้เลย ระบบเก็บผ่าน Supabase ไม่ต้องใช้ GitHub แล้ว

กำลังโหลดรีวิว...