This post has been de-listed
It is no longer included in search results and normal feeds (front page, hot posts, subreddit posts, etc). It remains visible only via the author's post history.
I have a pi zero that is in a cabinet and want to install buttons for power and reboot
I have the power connected using 5 6 and use this script
#!/usr/bin/python
import RPi.GPIO as GPIO
import time
import subprocess
GPIO.setmode(GPIO.BOARD)
GPIO.setup(5, GPIO.IN)
oldButtonState1 = True
while True:
#grab the current button state
buttonState1 = GPIO.input(5)
# check to see if button has been pushed
if buttonState1 != oldButtonState1 and buttonState1 == False:
# shutdown
subprocess.call("shutdown -h now", shell=True,
stdout=subprocess.PIPE, stderr=subprocess.PIPE)
oldButtonState1 = buttonState1
time.sleep(.5)
this works fine
what I am having trouble with is a script for rebooting or adding code to the first script
I have tried 21 and gnd and changed shutdown -h now to reboot now
but nothing happens when button is pressed
any ideas what I am doing wrong please ?
thanks in advance
Subreddit
Post Details
- Posted
- 2 years ago
- Reddit URL
- View post on reddit.com
- External URL
- reddit.com/r/raspberry_p...