Wiring 10 buttons...

I've got ten buttons to wire up to one Arduino. I was going to use external pull up resistors because I have relatively long (5m cables) between the Arduino and my buttons.

I wanted to use pull up resistors rather than pull down because my code logic is already factored for pull up resistors.

Is there a wiring diagram which shows the most efficient way to do this? I am presuming every button will need its own resistor, but I'm not sure.

Thank you

https://www.google.com/search?q=multiple+buttons+on+arduino+input

HTH.

Thanks, Erik, kind of - there's lots of advice to be found there for people interfacing with their buttons in all kinds of different ways, but I did find this thread, which is again, kind of useful.

The problem is, the vagueness of this question. Buttons in Parallel? Buttons in series? Buttons in some sort of array?

To save us from the travails of an "X-Y Problem" [see How To Use This Forum], please give us more information about the application, and how these 10 buttons apply.

Dan_ce:
I wanted to use pull up resistors rather than pull down because my code logic is already factored for pull up resistors.

So it should be, but the wiring does not follow the code; the code follows the wiring.

You connect the buttons to ground because that prevents you running a 5 V line to the buttons which would represent a risk of shorting it to ground. If a button line is shorted to ground, at worst the button is "stuck". :grinning:

For a 5 m run, you probably do want external pull-ups of a few k rather than relying on INPUT_PULLUP. The pull-ups will of course be on the assembly with the Arduino and you may wish to include 4k7 or 10k protective resistors between the incoming button line with the pull-up, and the Arduino.

And you will want to fully de-bounce the buttons in your loop() code to discriminate against potential interference pick-up as well as button bounce.

If you run short on I/O you can consider a PCF8575 expander module.

OTOH, if you matrix the buttons, 12 buttons (with diodes to permit more than one to be detected at once) could be wired with 7 wires/ Arduino pins, using CAT5 cable. :astonished:

You can try something as shown in /https://forum.arduino.cc/index.php?topic=432333.msg2981473#msg2981473 for longer distances.

hmmm. So I've got a little perfboard soldered up basically trying to do what the internal pull up resistor is doing but with an external resistor. So the same as the example on the right in this image?

Here is my perfboard.

When I check continuity with a multimeter and no button pressed, I don't have continuity. When I check when a button IS pressed, I DO. So sounds good, right?

Weirdly, when I hook up to the Arduino, it's not registering the button presses.

Now, at the moment I'm testing with my reasonably complicated codebase. I'm going to test tomorrow with a MUCH simpler sketch.

But I just thought I'd sanity check what I've soldered up before proceeding?!

Thanks!

Can't see a problem with the assembly.

Hmmm. Something's wrong. As soon as I connect the mini perfboard with the 10 resistors to the Arduino, it shorts out/resets. Checking continuity doesn't reveal any problems and debugging/troubleshooting this so far is taking ages and not revealing anything. Will continue to plod on.

Found it. Short between 3.3v and ground. Damnit. And the reason I didn't find it before was due to stupidity on my part.

Dan_ce:
Hmmm. Something's wrong. As soon as I connect the mini perfboard with the 10 resistors to the Arduino, it shorts out/resets. Checking continuity doesn't reveal any problems and debugging/troubleshooting this so far is taking ages and not revealing anything. Will continue to plod on.

Found it. Short between 3.3v and ground. Damnit. And the reason I didn't find it before was due to stupidity on my part.

I've been around a lot of people, and around myself, in the tech, and engineering world, and have witnessed similar "stupidity", at a frequency none of us would, likely, care to admit. :slight_smile: