const int relayPin = 23; // GPIO pin connected to the relay
const int ledPin = 22; // GPIO pin connected to the common terminal of the relay
void setup() {
pinMode(relayPin, OUTPUT); // Set relay pin as output
pinMode(ledPin, OUTPUT); // Set LED pin as output
digitalWrite(relayPin, LOW); // Ensure relay is off at startup
digitalWrite(ledPin, LOW); // Ensure LED is off at startup
}
void loop() {
// Turn the relay on (which will turn the LED on)
digitalWrite(relayPin, HIGH);
digitalWrite(ledPin, HIGH);
delay(1000); // Keep the relay on for 1 second
// Turn the relay off (which will turn the LED off)
digitalWrite(relayPin, LOW);
digitalWrite(ledPin, LOW);
delay(1000); // Keep the relay off for 1 second
}