I'm trying to make an arcade cabinet with my Raspberry Pi and I want to make a physical shutdown button for it. I can do this with the GPIO, I even wrote a python script to do it:
import RPi.GPIO as GPIO import time import os GPIO.setmode(GPIO.BCM) GPIO.setup(17, GPIO.IN, pull_up_down = GPIO.PUD_UP) while True: print GPIO.input(17) if(GPIO.input(17) == False): os.system("sudo shutdown -h now") break time.sleep(1)
I have a switch connected to GRD and to PIN17, that way when I press the button it shutdowns. The problem is I want the script to be running 24/7 so that whenever I push the button it shutdowns! How can I do that?
Note: I'm running RetroPie