High Level Math Question!

Hey arduinians,

I was working on a keypad one day when i came up with my own math problem that I could not solve!

Keypads are 0-9, I was trying to figure out the least number of digital pins needed using the on/off method rather than the resister/analog method.

I call this method, the and-gate-method.
(Someone probably came up with it already)

To confuse us less, lets say the keypad is A-Z and the numbers are digital pins.
with 1 pin i can have 1 letter
with 2 pins i can have 3 letters
with 3 pins i can have 7 letters
with 4 pins i can have 15 letters!

Confused? Example (3 pins):

A=1
B=2
C=3
D=1+2
E=1+3
F=2+3
G=1+2+3

The Ultimate Math question you’ve been waiting for!
What is the formula?
X represents digital pins
Y represents letters
:wink:

Is this not just binary arithmetic?

Number of button states (2 - on/off), raised to the power of (number of pins),

maybe -1, I haven’t thought this bit through much yet.

That is only if you want to be able to press one button at a time of course.
If the above is garbage please ignore it :slight_smile:

It seems you are correct!

This might be useful for anyone trying to do something using the least amount of wires. (keypads…).

Given n wires you can have them in 2n different states.

So with 4 wires you can have 16 states. You have to reserve a state for “nothing pressed” so you get
2n -1 keys