Reply To: Simple 1 button GPIO on off switch: 1 switch, 2 wires, 10 lines of code

Welcome Page 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

#122217
Profile photo of skizz
skizz
Participant

The I/O error only appeared when doing a sudo sh /home/pi/scripts/shutdown.sh command but as spaceinvader said the code would still work even with the error output so I’m not sure if it matters since echo I/O is a very vague error in linux apparently.

I think the big part was shorting the two pins longer than half a second. It must be the TTL logic firmware for the GPIO that needs longer than a certain pulse width to see a HIGH or LOW logic. Simply put, I was impatient haha.

I had to hold my momentary button at least a full second (1 mississippi) to get it to boot/poweroff.

Also if you guys want a to wire an external LED to show whether the Pi is on or off just wire the cathode (+) of a regular old LED with a resistor (500-1000 ohm is fine) to pin 8 (UART TXD) and then wire anode (-) to GND. That pin automatically pulls LOW when OFF and HIGH when ON so the LED will light accordingly and you don’t need to program or script anything (woot).

Thanks for the help and discussion.

Skip to toolbar