when I press the button, connected to ground, I receve a different binary number
Yes but make sure that the input pin is also connected to +5V through a resistor of value 1K to 10K. This is called a pull up resistor and ensures that the number read back contains a logic one when the button is not pressed. When the button is pressed that bit of the number will read as a logic zero.