Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/python3
- import RPi.GPIO as g
- from time import sleep
- from subprocess import Popen
- g.setmode(g.BCM)
- g.setup(26,g.IN)
- def p26_callback(channel):
- command = ['/usr/bin/sudo','poweroff']
- Popen(command)
- g.remove_event_detect(channel) # we've done it once, stop watching
- return
- g.add_event_detect(26, g.FALLING, callback=p26_callback)
- try:
- sleep(30)
- finally:
- g.cleanup()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement