All the Switches

I recently bought a heap of these switches – small DPDT toggle buttons – for $0.07 ea.

New-20PCS-Lot-7X7mm-7-7mm-6Pin-Push-Tactile-Power-Micro-Switch-Self-lock-On-Off.jpg_640x640[1]

Quantity over Quality

These switches are not that large, the on vs off height difference is only about a millimetre, and I hate to think what the ‘rated cycles’ or debounce graph looks like.
Regardless of their shortcomings, the prospect of having some silly project use literally THOUSANDS of switches on the cheap is enticing.

…but how to read them all?

The Problem

First of all, forget ‘one I/O per switch’, it will not scale well.

The most common method to wire up many switches is in a matrix.
Each row uses an I/O, each column uses an I/O, and pressing the switch connects that row and column together.
16 switches need 8 I/O, 64 switches need 16 I/O, it scales well. (and with a demux on one side, even fewer are needed)

Nobody can be told what the matrix is, you have to see it for yourself. (see above)

Nobody can be told what the matrix is, you have to see it for yourself. (see above)

However, switches are only simple electrical devices. When a switch is closed current can freely flow in either direction. If only one or two are closed, the patterns are unique. As soon as three or more switches are closed, a simple matrix can no longer read the switches with certainty. For example, there is no way to distinguish between these five switch states:

Which switch is which?

Indistinguishable patterns – Which switch is which?

The matrix option will not be able to read all the switches.

The Not-So-Great Solution

This is a common problem faced by designers. What is the common solution?
A diode can be placed next to each switch to allow current only in one direction.

I've got pain in the diodes down my left hand side...

I’ve got pain in the diodes down my left hand side…

“What’s wrong with that?” Well, every switch needs a diode.
So now there are twice as many parts on the board, and you’ve got to find space for them, pay for them, solder them in…not great at all.

Other Solutions?

What other options are there?