Adding a whole lot of tact switches

Does anyone know how to increase the digital input of Arduino? I want to be able to attach 26 tact switches to my standalone arduino board, but I have no clue where to start.

i2c , with the MCP23016 X 2 which will give you 32 input/ouputs and use a 10k resistor to gnd on each i/o and switch the other to +v

32 i/o and only 4 wire to the Arduino !!

Just using the plain Duemilanove you could [theoretically] have a matrix of 90 switches [using all 19 inputs]. That is: 9 x 10 matrix.

This would however render the serial lines unusable for communication and wouldn't allow for any other data connections.

But for 26 you could do a 13 x 2 matrix so you test the two columns separately, testing each 13 in each column.


peter247, I like your idea, but can you show a tutorial on how to connect this to an arduino board?

The part you want is something called a multiplexer. It's basically a multi-pole digital switch. The output line is connected to an input line determined by the values on the address lines. So, for instance, if you have a 16:1 multiplexer, you need to devote five pins to it: 1 input pin (to read the multiplexer output) and four output pins to serve as address lines. And you can use the same address lines for multiple muxes. So, if you have two 16:1 muxes, you can read 32 digital lines for the cost of six pins -- four address lines and two inputs (one for each mux).

The downside is that you can only read the switches by polling (sans additional cleverness), and this means you can't use them as interrupts and increases the minimum on time you can reliably detect over polling arduino pins directly. This shouldn't matter for tact switches, assuming that you have the extra cycles to poll at short intervals.

Depending on exactly what you want the switches to do, I'd think about using a PS2 PC keyboard, or the controller from a PS2 keyboard wired to different physical switches. This way you can attach 100+ switches to an arduino with two pins, and get press/release "events" rather than having to scan them all the time to see which ones are pressed, and debounce is handled by the keyboard controller. The disadvantage is that communications protocol is serial and rather slow; it can take a substantial amount of time (10s of milliseconds?) for keypress events to reach the arduino.

I've been experimenting with this, and have been meaning to write some instructions on using keyboards in this way, but so far real life has delayed things...