RaspiQRP/main.py

22 lines
523 B
Python
Raw Normal View History

2022-07-20 17:02:17 +03:00
import RPi.GPIO as GPIO
2022-07-20 17:05:19 +03:00
import asyncio
2022-07-20 17:02:17 +03:00
2022-07-20 17:05:19 +03:00
async def button_press(pin:int):
2022-07-20 17:02:17 +03:00
GPIO.setwarnings(False)
GPIO.setmode(GPIO.BOARD) # physical numbers
2022-07-20 17:13:34 +03:00
GPIO.setup(pin, GPIO.IN, pull_up_down=GPIO.PUD_UP)
while True:
button_state = GPIO.input(pin)
2022-07-20 17:14:31 +03:00
if button_state == True:
2022-07-20 17:13:34 +03:00
pass
else:
break
2022-07-20 17:02:17 +03:00
GPIO.cleanup()
2022-07-20 17:14:04 +03:00
await asyncio.sleep(.1)
2022-07-20 17:13:34 +03:00
return True
2022-07-20 17:02:17 +03:00
if __name__ == "__main__":
2022-07-20 17:07:34 +03:00
print(asyncio.get_event_loop().run_until_complete(button_press(19)))