5
\$\begingroup\$

I'm working on a Raspberry Pi project that requires 30 separate momentary switches to be hooked up to trigger the same function within the software. It's for an art project.

I don't need to distinguish between different buttons - I just need to register any button press - ideally on a single I/O pin for simplicity's sake, if possible.

My first thought is to simply wire up all the buttons in parallel, connected to a single I/O using the internal pull-up resistor. I know that in theory this should form a logical OR gate, which is what I want.

My question is: might multiple button presses cause unexpected behavior or potentially cause electrical damage to the Raspberry Pi? Or will this work as expected? If the former is true, what's the best way to achieve this?

\$\endgroup\$
  • 5
    \$\begingroup\$ Your first thought is alright. This technique is called Wired OR. \$\endgroup\$ – Nick Alexeev Oct 1 '15 at 21:56
7
\$\begingroup\$

No problem at all! You can put as many switches as you'd like in this configuration. I've also added a series resistor to protect the RPi GPIO pin as suggested in the comments.

schematic

simulate this circuit – Schematic created using CircuitLab

\$\endgroup\$
  • 3
    \$\begingroup\$ It's also advisable to add a series resistor between the switches / pullup resistor and the rPi GPIO pin. This reduces the chance that an ESD event might damage the pin on the rPi controller chip. 10k is a good value. \$\endgroup\$ – Dwayne Reid Oct 1 '15 at 22:27
  • \$\begingroup\$ Thanks for that, I've updated the schematic to include the series resistor. \$\endgroup\$ – Adam Oct 2 '15 at 7:54
1
\$\begingroup\$

Given this: -

Wetting current is the minimum amount of electric current necessary to keep a mechanical switch contact in good health. If a mechanical switch contact is operated with too little current, the contacts will tend to accumulate excessive resistance and may fail prematurely.

... and assuming you are providing enough wetting current for the switch(es) you'll be OK but please do ensure that earth loops are not created with other equipment if the switches are located remotely. If a remote connection is possible, you can wire-or all the switches together and feed the signal through an opto-isolator to the RaPi.

Wetting current

\$\endgroup\$
0
\$\begingroup\$

The other side of each button should all be connected to the same potential, so there won't be any issue assuming they are simple pushbuttons (i.e. minimal inductance, no voltage or current generation capability, etc.).

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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