Skip to content

Instantly share code, notes, and snippets.

@MCeddy MCeddy/shutdown.py
Last active Sep 1, 2017

Embed
What would you like to do?
raspberry pi 3 shudown button
import RPi.GPIO as GPIO
import os
BUTTON_PIN = 14
GPIO.setmode(GPIO.BCM)
GPIO.setup(BUTTON_PIN, GPIO.IN)
try:
channel = GPIO.wait_for_edge(BUTTON_PIN, GPIO.RISING)
if channel is not None:
# shutdown
os.system('sudo poweroff')
except KeyboardInterrupt:
print 'Ctrl-C - quit'
finally:
GPIO.cleanup()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.