Homepage Forums RetroPie Project GPIO Adapter, ControlBlock etc. Simple 1 button GPIO on off switch: 1 switch, 2 wires, 10 lines of code Reply To: Simple 1 button GPIO on off switch: 1 switch, 2 wires, 10 lines of code

#95928
tombofix
Participant

Amazing! Fitted with an old reset switch off a PC as they fit perfectly across the pins on a Pi 2.

Things to note:
Make sure your quote marks are the quote marks generated by nano. If you copy and paste the code your quotes and apostrophes will be incorrect and the script won’t run. It’ll typically result in an error about the directory not existing. If they look like they have curls then they aren’t correct.

rc.local should be
sudo sh /home/pi/scripts/shutdown.sh

I also found that I needed to install the GPIO components on my build before they worked.

sudo apt-get update
sudo apt-get remove python-rpi.gpio python3-rpi.gpio

Mine now works beautifully, can’t thank you enough as feel it is ready to be fitted in to a console!