Connecting a relay to an Arduino Uno allows you to control high-voltage or high-current devices such as lights, motors, or appliances using the Arduino’s low-voltage digital output pins. Here are the steps to connect a relay to an Arduino Uno:
Components Needed:
Arduino Uno
Relay module (typically a 5V relay)
Jumper wires
High-voltage or high-current device you want to control (e.g., a lamp)
Connections:
Relay Module – Arduino Connections:
- Relay VCC (usually marked “JD-VCC” or “VCC”) to Arduino 5V.
- Relay GND to Arduino GND.
- Relay IN (or signal pin) to a digital pin on the Arduino (e.g., D7).
Note: The number of IN pins may vary depending on your relay module. You can use any available digital pin on the Arduino to connect to the relay module’s IN pin.
High-Voltage or High-Current Device:
Connect the device you want to control using the relay to the relay module’s NO (Normally Open) and COM (Common) terminals. If you want the device to be normally off and turn on when the relay is triggered, connect it to the NO and COM terminals. If you want the device to be normally on and turn off when the relay is triggered, connect it to the NC (Normally Closed) and COM terminals.
Arduino Code:
Here’s a simple Arduino code example to control the relay. In this example, we’ll turn the relay on and off at intervals of a few seconds:
const int relayPin = 7; // Define the digital pin connected to the relay module’s IN pin
void setup() {
pinMode(relayPin, OUTPUT);
}
void loop() {
// Turn on the relay for 2 seconds
digitalWrite(relayPin, HIGH);
delay(2000);
// Turn off the relay for 2 seconds
digitalWrite(relayPin, LOW);
delay(2000);
}
Upload the code to your Arduino Uno, and the relay will turn on and off in 2-second intervals. You can modify the code to control the relay based on your specific project requirements.
Remember that relays are used for high-voltage or high-current applications, and proper caution should be exercised when dealing with high-power devices to ensure safety. Make sure to provide an appropriate power source to the relay module (usually 5V for the signal and the relay coil) and follow electrical safety guidelines for your specific application.





