17 lines
428 B
Python
17 lines
428 B
Python
import RPi.GPIO as GPIO
|
|
|
|
def button_press(pin:int):
|
|
def button_callback(channel):
|
|
GPIO.cleanup()
|
|
return True
|
|
|
|
GPIO.setwarnings(False)
|
|
GPIO.setmode(GPIO.BOARD) # physical numbers
|
|
|
|
GPIO.setup(pin, GPIO.IN, pull_up_down=GPIO.PUD_DOWN)
|
|
GPIO.add_event_detect(pin,GPIO.RISING,callback=button_callback)
|
|
GPIO.cleanup()
|
|
return False
|
|
|
|
if __name__ == "__main__":
|
|
print(button_press(19)) |