// Relay Demonstration
//
// 17 May 2024, by Koepel, Public Domain.
// The pins for the relay modules.
const int relay1Pin = 5;
const int relay2Pin = 4;
const int relay3Pin = 3;
const int relay4Pin = 2;
void setup()
{
// Set pins as output.
pinMode(relay1Pin, OUTPUT);
pinMode(relay2Pin, OUTPUT);
pinMode(relay3Pin, OUTPUT);
pinMode(relay4Pin, OUTPUT);
delay(1000);
}
void loop()
{
// Activate the relays one by one for one second.
// The relay module simulates a module that
// is activated with a high level at the "IN" pin.
digitalWrite(relay1Pin,HIGH); // Activate relay.
delay(1000);
digitalWrite(relay1Pin,LOW); // Release the relay.
delay(1000);
digitalWrite(relay2Pin,HIGH);
delay(1000);
digitalWrite(relay2Pin,LOW);
delay(1000);
digitalWrite(relay3Pin,HIGH);
delay(1000);
digitalWrite(relay3Pin,LOW);
delay(1000);
digitalWrite(relay4Pin,HIGH);
delay(1000);
digitalWrite(relay4Pin,LOW);
delay(1000);
}
uno:A5.2
uno:A4.2
uno:AREF
uno:GND.1
uno:13
uno:12
uno:11
uno:10
uno:9
uno:8
uno:7
uno:6
uno:5
uno:4
uno:3
uno:2
uno:1
uno:0
uno:IOREF
uno:RESET
uno:3.3V
uno:5V
uno:GND.2
uno:GND.3
uno:VIN
uno:A0
uno:A1
uno:A2
uno:A3
uno:A4
uno:A5
relay1:VCC
relay1:GND
relay1:IN
relay1:NC
relay1:COM
relay1:NO
relay2:VCC
relay2:GND
relay2:IN
relay2:NC
relay2:COM
relay2:NO
relay3:VCC
relay3:GND
relay3:IN
relay3:NC
relay3:COM
relay3:NO
relay4:VCC
relay4:GND
relay4:IN
relay4:NC
relay4:COM
relay4:NO
vcc1:VCC
led1:A
led1:C
r1:1
r1:2
r2:1
r2:2
led2:A
led2:C
gnd1:GND
led3:A
led3:C
r3:1
r3:2
r4:1
r4:2
led4:A
led4:C
led5:A
led5:C
r5:1
r5:2
r6:1
r6:2
led6:A
led6:C
led7:A
led7:C
r7:1
r7:2
r8:1
r8:2
led8:A
led8:C
NO = Normally Open (open when the relay is not activated)
NC = Normally Closed (closed when the relay is not activated)