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 ![]()