import machine
import time
# Define the relay pins
relay_pins = [
machine.Pin(14, machine.Pin.OUT), # Relay CH1
machine.Pin(15, machine.Pin.OUT), # Relay CH2
machine.Pin(16, machine.Pin.OUT), # Relay CH3
machine.Pin(17, machine.Pin.OUT), # Relay CH4
machine.Pin(18, machine.Pin.OUT), # Relay CH5
machine.Pin(19, machine.Pin.OUT), # Relay CH6
machine.Pin(20, machine.Pin.OUT), # Relay CH7
machine.Pin(21, machine.Pin.OUT) # Relay CH8
]
def control_relays():
while True:
for relay in relay_pins:
relay.value(1) # Turn relay on
time.sleep(2) # Wait for 1 second
relay.value(0) # Turn relay off
time.sleep(1) # Wait for 1 second
control_relays()