I have a project that has 4 buttons and I only have 3 pins available. I know there are various ways to put more than one button on a pin (e.g. resistor networks and analog reads) but I really just needed to free up one pin.
It occurred to me that I could do this easily by combing three of the four buttons into only two pins by using two diodes. The fourth button would have its own pin. For the other three I would end up with a truth table like this:
buttons pins (input) (output) B1 B2 B3 P1 P2 1 1 1 1 1 1 1 0 1 0 1 0 1 0 1 0 1 1 0 0
Of course this would work for 7 buttons on 3 pins or 15 buttons on 4 pins but it would involve an increasingly ridiculous number of diodes. There must be an IC that does what I want. It seems sort of like a multiplexor but it isn't quite that.
Is there any IC that performs this type of encoding?