1

I'm using a Raspberry pi to log GPS tracks in my car, so it's headless and has no network.

What is the simplest way to add a pushbutton to receive an input that will enable me to:

  1. stop the GPS daemon
  2. initiate a shutdown

I'm from a CS (Computer Science) background, so looking for the simplest circuit and the way to read the switch state via something like a cron job.

Bonus points for adding an LED I can turn off to confirm shutdown :)

Piotr Kula
17.3k6 gold badges67 silver badges105 bronze badges
asked Jun 4, 2013 at 18:51
2
  • What is CS background? Commented Jun 5, 2013 at 11:58
  • @ppumkin "Computer Science"? might be as well "Counter Strike", but I suspect the former, not the latter. Commented Jun 5, 2013 at 23:46

1 Answer 1

3

Here's the simplest circuit:

button schematics

you need to connect to the GPIO pin (choose one you like), +5V or +3V and GROUND. when you push the button, the state of GPIO pin should change. you may read it from the program or command file and do whatever you want to do.

If you want to control the LED, it's even easier. Connect GPIO pin to the 470ohm resistor to the LED to the ground. That's it. When GPIO pin is high, LED will be on, otherwise -- off.

answered Jun 5, 2013 at 11:28
2
  • 1
    Are you sure that using a pullup to 5V, won't damage the gpio pins that only accept 3.3v? Commented Jun 8, 2013 at 20:51
  • The Broadcom chip has build in pull-up resistors. You could use that instead of the resistor above. For safety I personally add a 2k resister between the button and the GPIO. This is in case I screw up and accidentally set the pin to output and high. As that would create a short between the GPIO's 3.3 volt and ground, frying the GPIO pin and maybe even the entire pi. Commented Jun 8, 2013 at 20:51

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.