from machine import Pin
import time
# GPIO pin numbers on Raspberry Pi Pico
RELAY_PIN = 21 # GP23
LED_PIN = 18 # GP18
relay = Pin(RELAY_PIN, Pin.OUT)
led = Pin(LED_PIN, Pin.OUT)
print("Relay + LED control started")
try:
while True:
relay.value(1) # ON
led.value(1) # ON
print("RELAY ON | LED ON")
time.sleep(2)
relay.value(0) # OFF
led.value(0) # OFF
print("RELAY OFF | LED OFF")
time.sleep(2)
except KeyboardInterrupt:
relay.value(0)
led.value(0)
print("Program stopped")