How can I connect multiple tact switches using a minimal amount of IO pins (without using an analog input)?

Let's say I hypothetically have ~12 buttons to connect with just a few (1 to maybe 4) digital pins. I don't want to use analog inputs. Is this possible without any multiplexing IC's?

Welcome to the forum

Use shift registers, or are they what you consider as multiplexing ICs ?

You could arrange your buttons in a 4x3 array and scan the array looking for a button press. It would require 7 digital pins to do it. If you want to use so few pins, then you may be looking for shift registers or an SPI (or I2C) i/o expander.

12 buttons on 4 pins without multiplexer or analog, nope.

push button matrix.

And the Keypad library.

MCP23017 (I2C) or MCP23S17 (SPI) 2 (I2C) or 4 (SPI) pins for 16 GPIO (buttons). Each input has optional internal pullup and pin change interrupt. That is how I would go if the matrix is out of the question.

Or have fewer tact switches where each switch does multiple things.

Could you elaborate? I haven't heard of shift registers. How would that work?

What does google say when you type in "shift register buttons"?

Using something like the 74HC165 parallel in serial out shift register you latch the inputs and shift the data out to the processor. Like on this page.

For the 74HC165 you will need an external pullup resistor for each switch. And you will need to poll for changes. The MCP parts that I mentioned have the pullups built in and can generate an interrupt for any button that changes state.

Thanks, I may check that out

check the SX1509 - available as breakout board.
it could handle a 4x4 button matrix and will do all the multiplexing for you.
But if you don't want to use them as matrix, you can read 16 lines also.

It uses I2C --> two wires, optional one "interrupt" line.

Sparkfun has a nice library and documentation for it. See their hookup guide!

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.