Code: Select all
import time
import RPi.GPIO as GPIO
GPIO.setmode(GPIO.BOARD)
GPIO.setup(7,GPIO.OUT)
try:
while True:
GPIO.output(7, GPIO.LOW)
print("0")
time.sleep(1)
GPIO.output(7, GPIO.HIGH)
print("1")
time.sleep(1)
finally:
# Reset the GPIO Pins to a safe state
GPIO.output (7, GPIO.LOW)
GPIO.cleanup()