Raspberry Pi - LED and Button Projects
Given the following code snippet, what will be printed when the button connected to GPIO 22 is pressed once?
import RPi.GPIO as GPIO
import time
def on_button_press(channel):
print('Pressed')
GPIO.setmode(GPIO.BCM)
GPIO.setup(22, GPIO.IN, pull_up_down=GPIO.PUD_UP)
GPIO.add_event_detect(22, GPIO.FALLING, callback=on_button_press, bouncetime=200)
while True:
time.sleep(1)