Raspberry Pi - LED and Button Projects
What will be the output behavior of this code snippet controlling an LED and button on Raspberry Pi?
import RPi.GPIO as GPIO
import time
GPIO.setmode(GPIO.BCM)
GPIO.setup(21, GPIO.OUT)
GPIO.setup(20, GPIO.IN, pull_up_down=GPIO.PUD_UP)
while True:
if GPIO.input(20) == GPIO.LOW:
GPIO.output(21, not GPIO.input(21))
time.sleep(0.3)
