When doing investigation on keypads/keyboards I realized all implementations are wired in matrix forms (columns and rows). This is a 2D approach, but we can take it a step further and use 3 dimensions (or more). This can give us more keys with the same amount of pins, depending on the number of keys / switches you have.
Here's a quick mockup.
Notes:
It might have some mistakes, as I haven't simulated it.
For the amounts of pins in the diagram, you would actually still get more keys with a 2 dimensional layout, but this was easier to demonstrate. By adding 2 more pins it would actually give more available keys.
The idea basically would be to scan both the columns as before, but adding a scanning of each layer. In the example above, we would scan;
iteration 1: set layer 0 to HIGH, layer 1 to LOW, set column 0 to HIGH, column 1 to LOW. Check rows.
iteration 2: set layer 0 to HIGH, layer 1 to LOW, set column 0 to LOW, column 1 to HIGH. Check rows.
iteration 3: set layer 0 to LOW, layer 1 to HIGH, set column 0 to HIGH, column 1 to LOW. Check rows.
iteration 4: set layer 0 to LOW, layer 1 to HIGH, set column 0 to LOW, column 1 to HIGH. Check rows.
As mentioned, depending on the number of available pins, the optimal number of dimensions varies.
Example 1:
If we have 6 pins, we would have 9 (3x3) available keys in a matrix layout.
Using a 3 dimensional layout we can only get 8 (2 x 2 x 2).
Matrix layout is better in this situation.
Example 2:
If we have 8 pins, we would have 16 (4x4) available keys in a matrix layout.
However, using a 3 dimensional layout we can get 18 (3 x 3 x 2).
3 dimensional layout is only slightly better, most likely not worth the effort.
Example 3:
If we have 12 pins, we would have 36 (6x6) available keys in a matrix layout.
However, using a 3 dimensional layout we can get 64 (3 x 3 x 3).
3 dimensional layout is vastly slightly better.
Taking it 1 step further; 4 dimensional layout with 12 pins gives us 81 keys (3x3x3x3).
This is more than double of the matrix layout. However, the extra complexity might make it not viable.
Pros and cons:
1-dimensional (a switch connects to a pin individually) and 2-dimensional (matrix) approaches are much simpler (and probably cheaper). They are also easier to solder, take up less space and are easier to troubleshoot.
N-dimensional approaches lets you use your more keys for the same amount of pins. They are slower too, as you need to scan layer by layer now, but for a low number of layers it's probably not an issue. I doubt that having more than 3 layers might be a nightmare to solder everything and still keep it relatively compact.
In the example above I used AND gates, which can be implemented with transistors, which are cheap, but if you use small micro controllers, then the price alone might perhaps make it more expensive. That will also take up a lot more space.
If you're just making a big box with a lot of buttons and don't care about the case being big, this might be viable for you.
Either way, I'm curious, has anyone ever done this and are my assumptions correct? Any other reasons why this isn't used?
