For this year’s RetroChallenge, I am hoping to interface an NES / Famicon controller to my RC2014 computer.
The NES controller has 8 buttons: Up, Down, Left, Right, Select, Start, A, and B.
The cable only has 7 pins, so how can it send up to 8 button presses using 7 wires?
Well, the NES controller only actually uses 5 of those wires. Two of those wires are GND and +5V. The other three are Latch, Clock, and Data.
Inside the controller, there is a 4021 shift register. When the Latch is pulsed from high to low, the 4021 captures the state of the buttons in 8 bits. The first capture bit will then be placed on the Data line. When Clock is pulsed from high to low, the 4021 will then shift the internal data one place forward, and the next bit will be placed on the Data line. When the next Clock pulse arrives, the next bit is sent, and so on. This needs to happen 8 times until all 8 bits have been sent. A low bit on the Data line means the button has been pressed; otherwise, the bit will remain high.
The bits are sent in the following order.
| Bit | Button |
| 0 | A |
| 1 | B |
| 2 | Select |
| 3 | Start |
| 4 | Up |
| 5 | Down |
| 6 | Left |
| 7 | Right |
Using software bit-banging, I should be able to send the Latch and Clock signals, and reassemble the received 8 bits back into a single byte.