import RPI.GPIO as GPIO
import time
GPIO.setmode(GPIO.BCM)
RELAY_PIN = 20
LED_PIN = 10
GPIO.setup(RELAY_PIN,GPIO.OUT)
GPIO.setup(LED_PIN,GPIO.OUT)
print("relay + led control statement")
try:
while True:
GPIO.output(RELAY_PIN,GPIO.HIGH)
Gpio.output(LED_PIN,GPIO.HIGH)
print("relay on | led on")
time.sleep(2)
GPIO.output(RELAY_PIN,GPIO.LOW)
Gpio.output(LED_PIN,GPIO.LOW)
print("relay off | led off")
time.sleep(2)
except KeyboardInterrupt:
print("program stopped by user")
finally:
GPIO.cleanup()