how to do the examples

How would I do this example:
With a button that has only two pins?

Right now, unless the button is pressed, I just get random values of the button.

The "top" and "bottom" of the button are internally connected. When pressed, the left and rigth rails will connect. Just move toe blue wire to under the resistor. Here is how it should be wired:

5V - Left of Button
Digital Pin - Right of Button
Right of Button - 10k Resistor - Ground