A relay module with Arduino is one of the most essential circuits in electronics engineering. A relay acts as an electrically operated switch that allows a low-power circuit to control a high-power device such as a light, motor or fan. It is widely used in automation projects, IoT systems and final year projects for students in Pakistan.

A relay is an electrically operated switch. When a small current flows through the coil, it creates a magnetic field. This field pulls a metal armature, which closes (or opens) a set of contacts, allowing current to flow through another circuit.
In simple terms, your Arduino board controls the small input current, while the relay switches a larger current for appliances. The relay module and Arduino combination provides isolation between the control and power circuits — the Arduino never touches the load's power directly, which is what makes the setup safe for automation and industrial projects.
Relays are crucial in IoT systems, Arduino robots, home automation and industrial control panels.
The load side of a relay module has three screw terminals. Understanding them is the whole point of the module:
For the light in this guide, use COM + NO: the bulb stays off until the Arduino turns the relay on.
There are two primary types of relays used in engineering projects:
These relays use physical moving parts to make and break electrical connections. They are common in DIY projects, school projects and basic automation systems. You can hear them click when they switch.
SSRs have no moving parts. They use semiconductor components for faster switching, long life and silent operation. They are ideal for industrial automation and CNC projects.
This guide uses the common 1-channel electromechanical relay module — the blue board with one relay, three control pins (VCC, GND, IN) and three screw terminals (COM, NO, NC).
| Component | Price / link |
|---|---|
| Arduino UNO R3 DIP | Arduino UNO R3 DIP ATmega328P with USB Cable — Rs 1,200 |
| 1-channel relay module 5V | 1 Channel Relay Module 5V — Rs 155 |
| Jumper wires | 40-Pin Jumper Wires 30cm — Rs 180 |
| 12V 2A AC/DC adapter (load power supply) | 12V 2A AC/DC Adapter — Rs 275 |
| 12V DC bulb (test load) | No QKZEE listing — available at the Hall Road shop on request |
| Relay module pin | Arduino pin |
|---|---|
| VCC | 5V |
| GND | GND |
| IN | D7 |
| Connection | Where it goes |
|---|---|
| 12V supply + | Relay COM terminal |
| Relay NO terminal | One side of the 12V bulb |
| Other side of the 12V bulb | 12V supply − |
When the relay is ON, COM connects to NO, the circuit closes, and the bulb lights. When the relay is OFF, COM disconnects from NO and the bulb goes out. The NC terminal is not used in this circuit.
A relay can switch 220V mains, but do not use mains for your first test. Test the circuit with the 12V DC bulb first — if the wiring is wrong, the worst that happens is a bulb that does not light. With 220V mains, a wrong wire can give you a serious shock or start a fire. Never touch the relay's screw terminals while the circuit is powered. If your project must switch a real 220V appliance, get an adult or an electrician to check your wiring before you plug it in, and never work on it while it is connected to the mains.
Arduino Code Example – Controlling a Light or Fanconst int relayPin = 7; // IN pin of the relay module
void setup() {
pinMode(relayPin, OUTPUT);
digitalWrite(relayPin, HIGH); // relay OFF (most modules are active LOW)
}
void loop() {
digitalWrite(relayPin, LOW); // relay ON — COM connects to NO, bulb lights
delay(3000);
digitalWrite(relayPin, HIGH); // relay OFF — COM disconnects from NO
delay(3000);
}Active LOW — read this before you upload. Most 1-channel relay modules are ACTIVE LOW: the relay clicks ON when IN is LOW and OFF when IN is HIGH. That is why the code above turns the relay on with LOW, not HIGH. The old version of this post did digitalWrite(relayPin, HIGH); // Turn ON relay — on the common active-low module, that leaves the relay OFF, and the bulb never lights. If your module is the active-HIGH type (it clicks when IN goes HIGH), swap the two writes.
This code alternates the relay ON and OFF every 3 seconds. You can use it to control a light, fan or even a motor. For IoT-based automation, this code can be modified using Firebase, Blynk IoT or ThingSpeak IoT platforms, which are frequently used in final year projects in Lahore and engineering universities across Pakistan.
Relay modules are vital components in both home and industrial automation. Let's look at some real-world applications:
Relays are used to control lights, fans and home appliances via Arduino or ESP8266 Wi-Fi boards. This setup is ideal for students aiming to build IoT smart homes.
In industrial projects, relays manage heavy machinery, CNC automation and motor controllers. They offer electrical isolation and safety.
Arduino robots often use relays to control motors, sensors and other components. It is a must-learn module for electronics engineering students working on final year projects.
Relays can also switch sensors, pumps or valves in medical science model projects and mechanical engineering projects.
We use the relay in our automatic tap water system — the IR sensor detects your hand and the relay switches the water pump on. We also use it in our IoT geyser safety system — the relay switches the heater off when the temperature gets too high.
The Arduino UNO (Rs 1,200), 1-channel relay module (Rs 155), jumper wires (Rs 180) and 12V 2A adapter (Rs 275) are available at QKZEE Technologies, Shop 20, 1st Floor, Al-Khalil Center, Hall Road, Lahore, and online at qkzeetech.com with delivery all over Pakistan — see the links above. The 12V DC bulb is available at the Hall Road shop on request.
If the relay does not click, or the bulb never lights, message us — tell us whether the relay clicks when you upload the code, and what the Serial Monitor shows, and we will help you find the fault.
Why does my relay not click?
Check the wiring (VCC → 5V, GND → GND, IN → D7) and that the Arduino is powered. If the module has a jumper between VCC and JD-VCC, leave it in place for this circuit — removing it is only for separate relay power supplies.
Why does the bulb never light even though the relay clicks?
The load side is wired wrong. Check: supply + → COM, NO → bulb, bulb → supply −. If you wired the bulb to NC instead of NO, the bulb will be ON when the relay is OFF and OFF when it is ON — swap NC for NO.
What is the difference between NO and NC?
NO (Normally Open) connects to COM only when the relay is ON — the load stays off until the Arduino turns it on. NC (Normally Closed) connects to COM when the relay is OFF — the load runs until the Arduino turns it off.
Can I switch a 220V bulb with this relay?
The relay's contacts are rated for it (most 1-channel modules are rated 10A at 250V AC), but do not do it as a first test. Test with 12V DC first, and get an adult or an electrician to check your mains wiring before you plug it in. Never touch the terminals while powered.
Why does my code turn the relay on with LOW?
Most 1-channel relay modules are active LOW — the relay clicks ON when IN is LOW. If your module is active HIGH, swap LOW and HIGH in the code.
Can I control the relay from my phone?
Yes — connect a NodeMCU or ESP32 instead of the UNO, and use Blynk or ThingSpeak to switch the relay from a phone. The relay wiring stays the same; only the control board changes.
When working with relay modules, always understand the voltage ratings and isolation requirements. Test with 12V DC first, never wire 220V mains live, and double-check your connections before powering the circuit. A relay is the part that lets a small Arduino control big things — learn its three terminals (COM, NO, NC) and its active-LOW behaviour, and you can switch almost anything safely.