# button setup (connect to GND and board Pin 21) import RPi.GPIO as GPIO # GPIO pins #import time def print_button(): GPIO.setmode(GPIO.BOARD) #Use the physical board number (not GPIO numbering) GPIO.setup(21, GPIO.IN, pull_up_down=GPIO.PUD_UP) #Change pin if necessary #print button GPIO.setwarnings(False) #Ignore warnings print_button_pressed = False if GPIO.input(21) == GPIO.LOW: #time.sleep(1) print_button_pressed = True GPIO.cleanup() #GPIO clean up return print_button_pressed