Wiring buttons to Arduino

I know that I can use an analog pin with resistors or use multiplexing, but I want to be able

In that case your only option is to use an Arduino with at least 20 digital input pins, like the Arduino Mega.

(Note that analog pins on Arduinos can generally also be used as digital inputs, but on the Uno that still only brings you up to 18 pins as you generally shouldn't use D0 and D1.)

That’s what I was thinking. Do you know if there is any multiplexing hardware that I can use with built in resistors/diodes?

Exactly what are you doing in this project ?

I am building a control panel with buttons and switches. I would like it to be easy to assemble (minimal wiring and no soldering).

That means a terminal/screw shield and a Mega.

If you think about it, a matrix will need less wiring than other methods. Without a matrix, you will need to have 21 wires going back to the Arduino. With a matrix, you will need only 9, plus some wiring to connect the rows and columns in the matrix.

Breadboards are only for building and testing your prototype circuit. Once it is working, you would not use a breadboard as a permanent circuit. You can use stripboard, protoboard or tri-pad board to solder up a permanent circuit, if you don't want to bother with designing a custom PCB. For one-off circuits where minimal size is not important, designing a custom PCB is probably not worth it, unless it's something you want to learn to do.

Resistors will not be necessary because you can use the Arduino's built-in pull-up resistors. Diodes are only needed in a matrix if you need to be able to identify more than one button being pressed at the same time, like on a querty or musical keyboard. If only one button will ever be pressed at any time, no diodes required.

SX1509

That's a bit like building something out of wood without using nails, screws or glue.

Could some soldering be done in advance by an adult so that the final circuit could be wired together by others without needing to solder?

What are the constraints of the project, and where do they come from?

You could use 3 PCF8574 boards: each allows for 8 I/Os. You read/write to them via I2C.
The boards are very cheap and the best is that many come with jumpers on the address bus, so theoretically, you could have 8 of these boards on the same bus and have 64 I/Os.

There are many tutorials on it.

Here is an example of what @PaulRB suggested.

... more than two buttons being pressed at the same time
:thinking:

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.