2015-05-08 21:27:28 +02:00
|
|
|
buttonpin=24
|
|
|
|
import RPi.GPIO as GPIO
|
|
|
|
import time
|
|
|
|
import os
|
|
|
|
|
2016-03-10 20:25:13 +01:00
|
|
|
|
2015-05-08 21:27:28 +02:00
|
|
|
GPIO.setmode(GPIO.BCM)
|
|
|
|
|
|
|
|
GPIO.setup(buttonpin, GPIO.IN, pull_up_down=GPIO.PUD_UP)
|
|
|
|
|
|
|
|
while True:
|
2016-04-01 00:36:44 +02:00
|
|
|
print("waiting...")
|
2016-03-10 20:25:13 +01:00
|
|
|
os.system('logger shutdownbutton waiting for press...')
|
2015-05-08 21:27:28 +02:00
|
|
|
try:
|
|
|
|
GPIO.wait_for_edge(buttonpin, GPIO.FALLING)
|
|
|
|
print('Button Pressed')
|
2016-03-10 20:25:13 +01:00
|
|
|
os.system('logger shutdownbutton pressen. bye bye')
|
2015-05-08 21:27:28 +02:00
|
|
|
os.system("shutdown now -h")
|
|
|
|
except KeyboardInterrupt:
|
|
|
|
GPIO.cleanup() # clean up GPIO on CTRL+C exit
|
|
|
|
GPIO.cleanup() #
|