// 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);
}
NOCOMNCVCCGNDINLED1PWRRelay Module
NOCOMNCVCCGNDINLED1PWRRelay Module
NOCOMNCVCCGNDINLED1PWRRelay Module
NOCOMNCVCCGNDINLED1PWRRelay Module
NO = Normally Open (open when the relay is not activated)
NC = Normally Closed (closed when the relay is not activated)