davezx
Posts: 43
Joined: Wed Jul 01, 2015 9:52 pm

momentary off button advice

Sat Sep 05, 2015 10:13 pm

I've been looking at this guide for a off button with script for shutdown procedure.

https://embeddedcode.wordpress.com/2013 ... pberry-pi/

These pins here.
https://embeddedcode.files.wordpress.co ... erside.png

It looks like it is for the pi 1 as mine is a pi2 b+ and I don't have the pins advised in the guide to use.
Can someone please advise on the pins to substitute the one's on the guide for the pi2 please.
Thankyou.

User avatar
Laurens-wuyts
Posts: 716
Joined: Wed Aug 21, 2013 7:35 pm
Location: Belgium
Contact: Website

Re: momentary off button advice

Sat Sep 05, 2015 10:25 pm

You can use any pin you like, GPIO 31 isn't connected to the header op the Pi 2B.
In the code of the tutorial, just change:

Code: Select all

GPIO.setup(31, GPIO.IN, pull_up_down = GPIO.PUD_UP)
GPIO.add_event_detect(31, GPIO.FALLING, callback = Shutdown, bouncetime = 2000)
to:

Code: Select all

GPIO.setup(x, GPIO.IN, pull_up_down = GPIO.PUD_UP)
GPIO.add_event_detect(x, GPIO.FALLING, callback = Shutdown, bouncetime = 2000)
where x is the GPIO number you used.

Laurens

davezx
Posts: 43
Joined: Wed Jul 01, 2015 9:52 pm

Re: momentary off button advice

Sat Sep 05, 2015 11:55 pm

That's good news thank you.
Can I write this in terminalx? And save it there.

Return to “General discussion”