Questo è un modulo relè a 5V a canale singolo, usato per commutare carichi a tensione o corrente più elevata con un segnale di controllo a bassa tensione. Il lato carico è nominale fino a AC250V 10A o DC30V 10A, quindi è adatto a progetti base di domotica e controllo.
| Pin | Segnale | Descrizione |
|---|---|---|
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 |
| Da | A | Filo |
|---|---|---|
board:5V |
x1:VCC |
red |
board:GND |
x1:GND |
black |
board:D7 |
x1:IN |
green |
Questo esempio è stato scritto e verificato in compilazione per arduino-uno. Codey Online lo adatta a qualsiasi altra scheda supportata.
// 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);
}
Descrivi cosa vuoi realizzare. Codey Online scrive il codice, disegna lo schema di collegamento, lo compila e programma la tua scheda direttamente dal browser.
Inizia gratis