Created
June 6, 2019 17:21
-
-
Save command-tab/b66107234c722115d1349339e8588b8f to your computer and use it in GitHub Desktop.
Revisions
-
commandtab created this gist
Jun 6, 2019 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,21 @@ #!/usr/bin/env python3 import RPi.GPIO as GPIO import asyncio import sys PIN = 18 def handle_edge(pin): print('Edge callback') if __name__ == '__main__': loop = asyncio.get_event_loop() try: GPIO.setmode(GPIO.BCM) GPIO.setup(PIN, GPIO.IN, pull_up_down=GPIO.PUD_DOWN) GPIO.add_event_detect(PIN, GPIO.RISING, callback=handle_edge, bouncetime=500) loop.run_forever() except KeyboardInterrupt: loop.close() sys.exit()