Develop a program to interface a relay with Arduino board.
To interface a 5V relay module with an Arduino Uno board and control the switching of an electrical load (such as a bulb, fan, or motor) using digital output signals. This experiment helps in understanding relay operation, electrical isolation, and Arduino-based switching applications.
Arduino Uno Board – 1
5V Relay Module – 1
Breadboard – 1
Jumper Wires – As Required
USB Cable – 1
Bulb (or Load Device) – 1
External Power Supply (for Load)
Step 1:
Take an Arduino Uno board, a 5V relay module, breadboard, jumper wires, USB cable, bulb (or any load), and an external power supply.
Step 2:
Connect the VCC pin of the relay module to the 5V pin of the Arduino Uno.
Step 3:
Connect the GND pin of the relay module to the GND pin of the Arduino Uno.
Step 4:
Connect the IN pin of the relay module to Digital Pin 4 of the Arduino Uno.
Step 5:
Connect the COM (Common) terminal of the relay to the Live (L) wire of the external power supply.
Step 6:
Connect the NO (Normally Open) terminal of the relay to one terminal of the bulb (or load).
Step 7:
Connect the other terminal of the bulb (or load) to the Neutral (N) wire of the external power supply.
Step 8:
Connect the Arduino Uno to the computer using a USB cable.
Step 9:
Open the Arduino IDE.
Step 10:
Select Tools → Board → Arduino Uno.
Step 11:
Select the correct COM Port.
Step 12:
Copy and paste the relay control program into the Arduino IDE.
Step 13:
Compile and upload the program to the Arduino Uno.
Step 14:
Observe the relay switching ON and OFF every second with an audible clicking sound.
Step 15:
Observe that the connected bulb (or load) also turns ON and OFF according to the relay operation.
Arduino 5V → Relay Module VCC
Arduino GND → Relay Module GND
Digital Pin 4 → Relay Module IN
Relay COM → Live (L) of External Power Supply
Relay NO → One Terminal of Bulb (Load)
Other Terminal of Bulb → Neutral (N) of External Power Supply
void setup()
{
pinMode(4, OUTPUT);
}
void loop()
{
digitalWrite(4, HIGH);
delay(1000);
digitalWrite(4, LOW);
delay(1000);
}
Read the full Viva Q&A for this program in a protected viewer, then download the PDF whenever you like.