

A relay is an electromechanical switch that uses an electromagnetic coil to open or close a circuit, allowing control of high voltage or high current devices with a low voltage signal. Relays are widely used in applications where electrical isolation, high-power switching, or remote control of circuits is required. They are commonly found in home automation systems, industrial control panels, automotive electronics, and power distribution systems.








Below is a typical pin configuration for a 5V SPDT relay:
| Pin Name | Description |
|---|---|
| Coil (+) | Positive terminal of the electromagnetic coil. Connect to the control voltage. |
| Coil (-) | Negative terminal of the electromagnetic coil. Connect to ground. |
| COM | Common terminal. Connect to the load circuit. |
| NO (Normally Open) | Open by default. Closes when the relay is activated. |
| NC (Normally Closed) | Closed by default. Opens when the relay is activated. |
Note: The pin configuration may vary depending on the relay model. Always refer to the datasheet for specific details.
Below is an example of how to control a 5V relay using an Arduino UNO:
// Define the relay pin
const int relayPin = 7; // Connect relay control pin to Arduino digital pin 7
void setup() {
pinMode(relayPin, OUTPUT); // Set relay pin as output
digitalWrite(relayPin, LOW); // Ensure relay is off at startup
}
void loop() {
digitalWrite(relayPin, HIGH); // Turn relay on
delay(1000); // Keep relay on for 1 second
digitalWrite(relayPin, LOW); // Turn relay off
delay(1000); // Keep relay off for 1 second
}
Important Considerations:
Relay Not Activating:
Load Not Switching:
Relay Buzzing or Clicking Rapidly:
Damage to Microcontroller Pins:
Q: Can I use a relay to control AC devices?
Q: What is the purpose of the flyback diode?
Q: Can I directly connect a relay to an Arduino pin?
Q: How do I choose the right relay for my project?