I had a Wikipedia blackout and got on the topic of NES controller circuit diagrams. Well, if you ever want to run in Super Mario Bros., remember: 01111101.
The 8 buttons on the controller are fed into an 8-bit shift register. The buttons are mapped to the register in the following order:
Right, Left, Down, Up, Start, Select, B, A
The inputs receive +5V by default (11111111), but when a button is pressed, a bridge is created to GND and the voltage drops to ~0V. The new value is updated in the register (this is constantly being advanced/cleared using a clock line and a pulse line).
The controller then sends that value to the system through the controller input port, which is then passed on to the game cartridge. Now the game knows to animate the character sprite differently and scroll the screen faster!
For a more detailed explanation on the controller diagram, check out this link.