Go Down

Topic: New matrix keypad: 1 analog pin, 3 digital pin, 5 10K resistors, 15 buttons (Read 2050 times) previous topic - next topic


As many of you may know that there is thing called an analog button. You use one analog pin to sense a few buttons:


There are a few drawbacks to this design so I made some improvements.

1) You can not have too many buttons, or the analog values get too close. Considering resistors can be only as accurate as 1% (not paying for high precision resistors), if you produce a product that needs 10 resistors, chances are, your analog values are getting quite close. It's not even split from 0 to 1023.

2) You can have more buttons if you use two or more analog pins but each group of buttons need their separate resistors. Too many resistors.

1) Use the internal pull-up to save one resistor (or not).
2) Use digital pins to scan a matrix of buttons all hooked up to one set of resistors.

Here is what I came up with (about 2 years ago):

So I used this design on my phi-panel to save some pins. I also attached one button directly to 5V. This is problematic only when this key is pressed with another key in the matrix, which I should tell the panel users not to do. A typical matrix keypad with 16 keys costs 8 digital pins, a bit too many. This one only costs 4 pins. Any interest? Comments?
Serial LCD keypad panel,phi_prompt user interface library,SDI-12 USB Adapter


Have you considered using a log scale of resistances, one across each button?  e.g. 250, 500, 1k, 2k, 4k, 8k, 16k, etc.  That way you should be able to get maybe 7 buttons working in a single chain with 1% resistors and be capable of detecting the exact combination of buttons that are depressed, before the value error in the largest resistance swamps the smallest.  And you can make the chain longer if you are willing to calibrate the voltages produced by each chain.

If you can accurately detect a voltage from 1 of 2^(n+m) options, I think that allows you to build a single-pin n*m matrix if at most one button is pressed at a time: drive all columns constantly, each through a different large resistance.  Put your small resistances in series with each button, with a different value on each row.  When one button is pressed, you will observe R_column+R_row to ground, which should produce a unique voltage.  So one analog pin should give you at least a 3x3 keypad (2^6=64 levels, definitely OK with 1%); with some care and/or calibration, you should be able to do 256 levels = 2^8 = 4x4.

I'm not convinced that this is easier or cheaper for large matrices than just using a pair (1 in, 1 out) of shift registers.  A pair of 8-bit registers will let you scan an 8x8 matrix and you can expand it as far as you like by just chaining the carry bits.  The registers are probably cheaper than all those resistors too, and they're compatible with buttons that have non-zero closed resistance.

Go Up