import RPi.GPIO as GPIO
import time
GPIO.setmode(GPIO.BCM)
RELAY_PIN = 13
LED_PIN = 18
GPIO.setup(RELAY_PIN, GPIO.OUT)
GPIO.setup(LED_PIN, GPIO.OUT)
print("Relay + LED control started")
try:
while True:
GPIO.output(RELAY_PIN, GPIO.HIGH)
GPIO.output(LED_PIN, GPIO.HIGH)
print("Realy ON | LED ON")
time.sleep(2)
GPIO.output(RELAY_PIN, GPIO.LOW)
GPIO.output(LED_PIN, GPIO.LOW)
print("Realy OFF | LED OFF")
time.sleep(2)
except KeyboardInterrupt:
print("Program stopped by user")
finally:
gpio.cleanup()