Electrical – Reducing the number of pins needed to read a 12-key keypad where the buttons are grounded

encoderkeypadmultiplexer

Unfortunately, I'm not sure what the right question is; I'have a 12-key keypad. I wanted to utilise a matrix based approach, except that they all seem to be connected in such a way, that they're floating when not pressed; when you press one, it connects to ground. This seems to me as if it's prepared for a set-up with a pull-up resistor on the wire over to the MCU, and not a matrix-style reading, where I (if I understand correctly) sequentially pulse on the rows, and sequentially read the voltage on columns.

However, I don't have 12 spare pins on my MCU, so I'm wondering how to minimize the number of pins needed to read this 12-key keypad.

Are there any ICs that I might use? Any approaches?

If I recall correctly, the board it used to be connected to had several (de)multiplexers connected in cascade, but I couldn't figure out the way it worked. However, I'm pretty sure the keypad itself is wired like this (it has its own connector as it's on a separate board which I'd like to keep), and that makes me confused.

Best Answer

Here ya go. Schematic below. I've only shown 8 buttons, but 74HC4067 has 16 analog channels for up to 16 buttons.

Select which button you want to check by driving the 4 bit line to the desired channel, then read the MCU input. High = button not pressed. Low = button pressed.

Simple debounce algorithm is to only scan say 30x per second max.

schematic

simulate this circuit – Schematic created using CircuitLab