This is a 5V single-channel relay module used to switch higher-voltage or higher-current loads with a low-voltage control signal. It is rated for up to AC250V 10A or DC30V 10A on the load side, making it suitable for basic home-automation and control projects.
| Pin | Signal | Description |
|---|---|---|
NC |
Normally-closed relay contact, connected to COM when relay is not energized | |
COM |
Common relay contact for the switched load circuit | |
NO |
Normally-open relay contact, connected to COM when relay is energized | |
GND |
ground | 0V ground reference for the 5V control input side |
VCC |
power | 5V supply input for the relay module coil and control circuitry |
IN |
digital | Active-low logic control input; drive low to energize the relay |
| From | To | Wire |
|---|---|---|
board:5V |
x1:VCC |
red |
board:GND |
x1:GND |
black |
board:D7 |
x1:IN |
green |
This example was written and compile-checked for the arduino-uno. Codey Online adapts it to any other supported board for you.
// Canonical example for a 5V 1-channel relay module
// The relay input is active-low:
// LOW = relay ON
// HIGH = relay OFF
const int RELAY_PIN = 7;
void setup() {
pinMode(RELAY_PIN, OUTPUT);
Serial.begin(9600);
while (!Serial) {
;
}
// Start with the relay turned off.
digitalWrite(RELAY_PIN, HIGH);
Serial.println("Relay module example started.");
Serial.println("Sending LOW turns the relay ON, HIGH turns it OFF.");
}
void loop() {
Serial.println("Relay ON");
digitalWrite(RELAY_PIN, LOW);
delay(1000);
Serial.println("Relay OFF");
digitalWrite(RELAY_PIN, HIGH);
delay(1000);
}
Describe what you want to build. Codey Online writes the code, draws the wiring diagram, compiles it and flashes your board straight from the browser.
Start for free