Lightning button on the rear...?

Here is all the tutorials, FAQ and support for RaspiBoy Kit
roostaar
Posts: 31
Joined: Tue 2 Jan 2018 00:39

Re: Lightning button on the rear...?

Post by roostaar »

I found a small note in the installation guide...

“5 - V1.2 Has some difference :

Button with a lightning bolt at the back is now a GPIO button.”

So what can we do with the his GPIO button??
Graylag
Posts: 8
Joined: Tue 12 Dec 2017 12:51

Re: Lightning button on the rear...?

Post by Graylag »

On v1.2 revision (second batch) devices it does nothing on default. But it is connected to one of the GPIO pins of raspberry (specifically GPIO 17) and it can be accessed from command line, through script or other programs. So in theory it can be used for anything and only your programming skills are the limit.

Most obvious use would be as shutdown or soft reset button, checked by bash script. But it might be programmed even as controller button.

Personally I intend to programm it as soft reset button and cut it flat with case to prevent accidental pushing. This would be great for those "stucked" situation where you don't have keyboard around to restore (typically "file manager" - this one is my personal nightmare). Only I have been too busy playing instead of programming :D
roostaar
Posts: 31
Joined: Tue 2 Jan 2018 00:39

Re: Lightning button on the rear...?

Post by roostaar »

Cheers for reply

I have tried using the program 'retrogame' to program the button but having followed the instructions, still cannot get it to simulate a keypress.

Fancy giving it it a go?

https://learn.adafruit.com/retro-gaming ... s-software
thomas
Posts: 3
Joined: Thu 4 Jan 2018 13:15

Re: Lightning button on the rear...?

Post by thomas »

This Tutorial ist based on http://www.instructables.com/id/Simple- ... wn-Button/.

Download the script:

Code: Select all

wget http://tinyurl.com/off-button-py -O /home/pi/off-button.py
alternatively

Code: Select all

wget https://www.instructables.com/files/orig/FVM/K0WJ/IA0WRZBF/FVMK0WJIA0WRZBF.py -O /home/pi/off-button.py
edit the script:

Code: Select all

nano /home/pi/off-button.py
replace

Code: Select all

gpio_pin_number=YOUR_CHOSEN_GPIO_NUMBER_HERE
with

Code: Select all

gpio_pin_number=17
Set the Script to Run at Boot-up:

Code: Select all

sudo nano /etc/rc.local
and write befor

Code: Select all

exit 0
the line

Code: Select all

python /home/pi/off-button.py &
Don*t forget the & sign on the end, otherwise the Pi does hang in the bootprozess.
roostaar
Posts: 31
Joined: Tue 2 Jan 2018 00:39

Re: Lightning button on the rear...?

Post by roostaar »

Hi Thomas

Thanks for this!

Have tried the steps but no joy. :?

Have you tried this successfully?

Cheers
breeman
Posts: 3
Joined: Mon 18 Dec 2017 21:04

Re: Lightning button on the rear...?

Post by breeman »

I followed this tutorial for a soft shutdown button https://www.youtube.com/watch?v=4nTuzIY0i3k

And I got it working with the following script (they used Pin 5, Lightning button uses Pin 11)

Code: Select all

#!/usr/bin/python
import RPi.GPIO as GPIO
import time
import subprocess

GPIO.setmode(GPIO.BOARD)  

GPIO.setup(11, GPIO.IN, pull_up_down = GPIO.PUD_UP)  

oldButtonState1 = True

while True:
    #grab the current button state
    buttonState1 = GPIO.input(11)

    # check to see if button has been pushed
    if buttonState1 != oldButtonState1 and buttonState1 == False:
      subprocess.call("shutdown -h now", shell=True, 
        stdout=subprocess.PIPE, stderr=subprocess.PIPE)
      oldButtonState1 = buttonState1

    time.sleep(.1)
roostaar
Posts: 31
Joined: Tue 2 Jan 2018 00:39

Re: Lightning button on the rear...?

Post by roostaar »

Thanks for this breeman

I have followed this to the letter and it still won't work for me!

Is it possible my BIB is not actually connected to ground/faulty?

I have tried this so many times now. :(
Vilikt
Posts: 15
Joined: Mon 15 Jan 2018 11:13

Re: Lightning button on the rear...?

Post by Vilikt »

Try to add

Code: Select all

(sleep 10;python /home/pi/off-button.py) & 
instead of simply

Code: Select all

python /home/pi/off-button.py &
roostaar
Posts: 31
Joined: Tue 2 Jan 2018 00:39

Re: Lightning button on the rear...?

Post by roostaar »

Vilikt wrote:Try to add

Code: Select all

(sleep 10;python /home/pi/off-button.py) & 
instead of simply

Code: Select all

python /home/pi/off-button.py &
Thank you for your advice. Still no joy i'm afraid...

BTW, what does 'sleep 10;' do to the code?
roostaar
Posts: 31
Joined: Tue 2 Jan 2018 00:39

Re: Lightning button on the rear...?

Post by roostaar »

Ok, so I rigged up an arcade button to my RPi3 to pins 5 & 6 and followed the tutorial by barryhubbard.

http://www.barryhubbard.com/raspberry-p ... io-button/

This works perfectly on my RPi3!

I followed the steps again for my Raspiboy and altered the script to Pin 11 and nothing.

Surely I have a dodgy PCB?

Edit: Have just tried a fresh clean install with a different SD on RetroPie 4.3 and same result. :(
Post Reply