diff --git a/main.py b/main.py index 24cfff3..0cbb1ee 100644 --- a/main.py +++ b/main.py @@ -2,18 +2,21 @@ import RPi.GPIO as GPIO import asyncio async 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.setup(pin, GPIO.IN, pull_up_down=GPIO.PUD_UP) + while True: + button_state = GPIO.input(pin) + if button_state == False: + pass + else: + break + GPIO.cleanup() - asyncio.sleep(5) - return False + asyncio.sleep(1) + return True if __name__ == "__main__": print(asyncio.get_event_loop().run_until_complete(button_press(19))) \ No newline at end of file