Shutdown Switch shuts pi down permanently!
  • I've followed the instructions as per http://pimame.org/forum/discussion/comment/1983#Comment_1983 which if I understood correctly installs a python package which allows for shutdown and sets up a python script to shutdown upon button press.

    I have one of these connected to the GPIO - http://www.maplin.co.uk/p/gpio-board-with-terminal-block-for-raspberry-pi-n31nt

    Then to pin P17 and GND the 2 cables from a press switch (http://www.arcadeworlduk.com/products/Happ-Mini-Round-Momentary-Arcade-Button.html)

    I've followed this process twice now but both times on boot up the pi powers up but powers down pretty much straight away.

    Is my set up wrong somehow?

    I set the pi to boot straight into the mame4all menu system if that matters?
  • Thanks I'll go through this and give it a try...
  • Thanks for your help. It definitely is GPIO17 because Maplin's terminal block maps to GPIO17. I connected one end of the plunger to GPIO17 and the other to GND.

    I've changed the code as follows:

    import RPi.GPIO as GPIO
    import time
    import os
    GPIO.setmode(GPIO.BOARD)
    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)

    Then saved this as shutdown.py and edited file /etc/rc.local to add:
    python /home/pi/bin/shutdown.py &
    (before last line)

    Still no working...

    I know that I have the pi booting straight into Mame4All by adding a line in the .profile file. Would this somehow stop the rc.local file from loading and therefore not executing the script?
  • This is solved now - thanks for your help.

    The GPIO.BOARD did need to be GPIO.BCM - works perfect...

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!