4-Channel Relay Module with Arduino UNO
Control four independent AC or DC appliances using a microcontroller. Learn relay interfacing, digital output control, and safe high-voltage switching — with complete code, wiring, and simulation.
What You'll Build
An Arduino-controlled switching system that lets you independently turn ON and OFF four high-voltage loads — bulbs, fans, motors, or any AC/DC appliance — using low-power 5V digital signals. The circuit was designed and simulated using Cirkit Designer.
Difficulty
Beginner
Build Time
30–60 Minutes
Loads Controlled
4 Channels
Supply Voltage
5V (Arduino)
What You'll Learn
Each relay channel is wired to a separate Arduino digital pin, giving you full individual control over every load.
Learn how a LOW or HIGH signal from an Arduino pin energises a relay coil to switch the mechanical contact.
Use pinMode(), digitalWrite(), and delay() to sequence relay switching with precise timing.
How a Relay Works
A relay is an electromechanical switch that lets a low-voltage circuit (Arduino 5V) safely control high-voltage appliances (up to 230V AC or 12V DC). Most 4-channel modules include an optocoupler for electrical isolation between the Arduino and the high-voltage side.
The 5-Step Switching Sequence
A digital write to pins 2–5 sends a 5V or 0V signal to the relay module's IN terminals.
The optocoupler isolates the Arduino from the relay coil driver transistor.
Current flows through the coil, generating a magnetic field strong enough to pull the internal armature.
The armature moves, shifting the COM contact away from NC (Normally Closed) to NO (Normally Open).
The connected load is either energised (COM→NO) or de-energised depending on your wiring choice.
Relay Terminal Reference
COM — Common
Always connected to your power supply line. This is the shared terminal for both NO and NC contacts.
NO — Normally Open
Open (disconnected) when relay is OFF. Closes when the coil is energised. Use for devices you want ON when triggered.
NC — Normally Closed
Closed (connected) when relay is OFF. Opens when coil energises. Use for fail-safe circuits that must stay ON by default.
Components Required
| Component | Qty | Notes |
|---|---|---|
| Arduino UNO (R3) | ×1 | Main controller — runs all switching logic |
| 4-Channel Relay Module (5V) | ×1 | Optocoupler-isolated, active-LOW or active-HIGH (check your module) |
| Jumper Wires (M-M, M-F) | ×15+ | For all signal and power connections |
| 5V USB / DC Power Supply | ×1 | Powers Arduino (and relay module via Arduino 5V pin) |
| AC/DC Loads | ×4 | Bulb, fan, motor, LED strip — one per channel |
| Insulated wire (for AC side) | — | Rated for mains voltage if using 230V AC loads |
HIGH turns the relay OFF and LOW turns it ON. Check your module's datasheet and swap logic if needed.Wiring Diagram
Pin Connection Table
Power Connections
Signal Connections
Load Wiring (per channel)
Step-by-Step Instructions
Gather All Components
Collect your Arduino UNO, 4-channel relay module, jumper wires, power supply, and test loads (LEDs or light bulbs). Ensure your relay module is rated for 5V coil voltage and matches your load's voltage and current requirements.
Connect Power to the Relay Module
- Relay module VCC → Arduino 5V pin
- Relay module GND → Arduino GND pin
Connect Signal (Control) Wires
- Relay IN1 → Arduino D2
- Relay IN2 → Arduino D3
- Relay IN3 → Arduino D4
- Relay IN4 → Arduino D5
Use male-to-female jumper wires. Ensure no bare wire ends are exposed.
Wire Your Loads (High-Voltage Side)
For each channel, connect your load between the COM and NO terminals. The other end of the load goes to Neutral (for AC) or Ground (for DC).
Install Arduino IDE & Open Sketch
Download the Arduino IDE from arduino.cc. No additional libraries are needed — this project uses only built-in Arduino functions.
Upload the Code
Copy the full sketch from the Code section below. Connect Arduino via USB, select Board → Arduino UNO and the correct Port, then click Upload (→ arrow icon).
Power On and Test
After uploading, power on the system. You should hear each relay click in sequence every 1 second — Relay 1 → Relay 2 → Relay 3 → Relay 4 → repeat. Each connected load should turn ON then OFF in turn.
- If no click: check VCC/GND wiring and verify 5V at the module
- If all relays trigger at once: you may have an active-LOW module — invert your
HIGH/LOWlogic - If load doesn't switch: verify COM/NO wiring on the output side
Full Source Code
// ───────────────────────────────────────────────────── // 4-Channel Relay Module with Arduino UNO // MakeMindz.com | Controls 4 loads independently // Simulated with Cirkit Designer // ───────────────────────────────────────────────────── // Define relay control pins const int relay1 = 2; // IN1 → Channel 1 const int relay2 = 3; // IN2 → Channel 2 const int relay3 = 4; // IN3 → Channel 3 const int relay4 = 5; // IN4 → Channel 4 // ── setup() ────────────────────────────────────────── // Runs once on power-up or reset void setup() { // Configure all relay pins as digital outputs pinMode(relay1, OUTPUT); pinMode(relay2, OUTPUT); pinMode(relay3, OUTPUT); pinMode(relay4, OUTPUT); // Ensure all relays start in the OFF state // (HIGH = OFF for active-LOW modules) digitalWrite(relay1, HIGH); digitalWrite(relay2, HIGH); digitalWrite(relay3, HIGH); digitalWrite(relay4, HIGH); } // ── loop() ─────────────────────────────────────────── // Repeats forever: toggles each relay ON for 1s, then OFF void loop() { // ── Relay 1 (Channel 1) ────────────────────────── digitalWrite(relay1, HIGH); // Turn ON (LOW for active-LOW modules) delay(1000); // Wait 1 second digitalWrite(relay1, LOW); // Turn OFF delay(1000); // Wait 1 second // ── Relay 2 (Channel 2) ────────────────────────── digitalWrite(relay2, HIGH); delay(1000); digitalWrite(relay2, LOW); delay(1000); // ── Relay 3 (Channel 3) ────────────────────────── digitalWrite(relay3, HIGH); delay(1000); digitalWrite(relay3, LOW); delay(1000); // ── Relay 4 (Channel 4) ────────────────────────── digitalWrite(relay4, HIGH); delay(1000); digitalWrite(relay4, LOW); delay(1000); // After all 4 cycles, the loop restarts from Relay 1 }
HIGH and LOW in the loop() function. Set pins HIGH in setup() to keep relays off at startup.Test Without Hardware
Simulate in your browser — no relay or Arduino required
Use Wokwi or Cirkit Designer to visualise the circuit. Load the diagram.json above into Wokwi, paste the code, and press Run to see the relay logic execute with LED indicators for each channel.
diagram.json, create a new file sketch.ino and paste the code. The relay module is available as wokwi-relay-module. LEDs replace real loads since Wokwi doesn't simulate AC mains for safety.Key Features
4 Independent Channels
Each relay is fully independent — different loads, different timings, full control.
Electrical Isolation
Built-in optocoupler separates the Arduino signal side from the high-voltage load side.
Safe High-Voltage Switching
Switch 230V AC or 12V DC loads safely using just 5V Arduino digital signals.
Home Automation Ready
Foundation for smart home projects — add Bluetooth, WiFi, or RFID for remote control.
Applications
Home Automation
Control lights, fans, and appliances from a central Arduino system.
Smart Irrigation
Schedule water pumps based on soil moisture sensor readings.
Industrial Automation
Sequence solenoids, motors, and actuators in production lines.
IoT Smart Switches
Combine with ESP8266/ESP32 for Wi-Fi controlled switching from any device.
.png)
Comments
Post a Comment