I have a Raspberry Pi 1 Model A and have a simple hobby project I'm tinkering with. I will have two pushbuttons (PB1 and PB2 respectively) wired to the GPIO pins, as well as a buzzer and an LED. The idea is to power this on with batteries.

When the pi is powered on, Raspbian will start up and a syste service (daemon) that I write will start up. Once this service is running it will power on the LED and keep it turned on until the service shuts down or the pi is powered off (obviously).

If both PB1 and PB2 are pushed at the same time, this running service will detect this and will cause the buzzer to sound. If either pushbutton is released the service will detect this and turn the buzzer off. Really simple. (Yes I realize I could accomplish this without the pi but there's more to the story here.)

I want to make sure that the hardware I've selected is compatible with my pi (especially the buzzer) and that I'm not gonna fry my pi.

The pushbuttons:

  • RadioShack brand (275-1566)
  • Momentary Pushbutton Switch
  • Contacts rated at 3A at 125VAC; 1A at 250VAC

RadioShack brand (275-1566)

The LED:

  • RadioShack brand (276-0307)
  • 5mm
  • 1.7V
  • 20mA

RadioShack brand (276-0307)

The buzzer:

  • RadioShack brand (273-0793)
  • 6VDC

RadioShack brand (273-0793)

Can I wire these components directly to my pi's GPIO pins or should I put any protective elements (resistors, etc.) in between them? Keep in mind that there would be periods of time when all of them would be operating at the same time (the pushbuttons are being pushed, the LED is being lit up and the buzzer is sounding). Or are there other parts with different ratings that I should be using? What types of batteries would work for this project (it's fine if I have to replace the batteries often, they don't have to be heavy duty this is just a toy project). Thanks in advance!


1 Answer 1


From the schematic of the Raspberry Pi it looks like the GPIO have limited chip protection on the board. https://www.raspberrypi.org/app/uploads/2012/04/Raspberry-Pi-Schematics-R1.0.pdf

So you should use a pull up/down resistor to ensure some regulated power for the button logic and have the inputs connected to the GPIO pins like this: http://www.madsciencenotebook.com/files/pullup.png

Driving the LED will also require a resistor or two to get the current through the LED correct. You'd also want to drive the speaker from a power rail with a switch as the Pi might not be able to supply the 6V for driving you speaker, I'm not sure what the exact output voltage of a Pi PINs are but I don't think it's over 5V. http: //www.electronicshub.org/wp-content/uploads/2015/02/Driving-a-Speaker.jpg

As for batteries a 9V with basic voltage regulation to supply 6V for the components and 5V 1.2A for the Pi or you could use 4 AA batteries but one 9V would be cheaper.

Hope this helps.

  • Good answer - a couple things to add: 1. The resistor for the LED is to make sure the LED does not burn out (versus the Pi). 2. There are internal pull ups/downs you can set on the GPIO pins so you don't have to buy more, 3. The Pi has a built in audio jack which might be easier than the buzzer, 4. TI has a snazzy buck-boost converter PTN04050C which you can get from the sample program. Just takes a resistor to set up.
    – combo
    Sep 1, 2017 at 15:56

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.