How do you optimize the electronic circuit of a keyboard ? It has
- $N$ keys $\{n_0,...n_{N-1}\}$
- a micro-controller with $P$ pins $\{p_0,...p_{P-1}\}$
- you wish to dinstinguish any $K$ key combination
A pin can be in any of the following $4$ states : $\{W_+,W_0,R_+,R_0\}$ that are read and write for +3V or ground.
A button has $2$ connectors that can be either connected or disconnected depending on the press state.
Should I worry about shortcircuiting a $W_+$ pin with a $W_-$ pin ? Or are there simple solution about that ?
Any $K$ combination means we need at least $∑_{k=1}^{K}\frac{N!}{k!(N-k)!}$ possible states for the micro-controller pins (with some constraints as any pin could be R or W, you need at least one R pin)
Pins have $4^{P}$ states but $2^{P}$ correspond to "no read pins" states. We have at maximum $4^{P} - 2^{P}$ exploitable states
could we actually use solid state stuff to improve interaction ? in which case we may exploit the "all write" case for a later readout...
We could use many diodes to make use of the same circuit in a very different manner depending on what pin is in write or read mode.