How to make a button activate its corresponding binary address
The most direct way to do it is to build a diode matrix:







simulate this circuit &ndash; Schematic created using CircuitLab

The diodes in each column directly encode the "address" of the switch.

Note that I'm assuming that the inputs rise to a positive voltage if not grounded; i.e., they source current when grounded. (Add pullup resistors if necessary.) If the voltage is negative, then reverse the direction of the diodes.