Untitled Document

Untitled Document


Decoding NES Controllers

Synlor- 27th February 2005

The NES controller is a simple device that uses serial communication to determine which buttons are pressed.

History: V. 0.1 First document


  • 16F628 PIC MCU
  • NES Controller

Disclaimer: I am not responsible of what you do with these directions, nor responsible for what it can do to your dreamcast, vmu, or anything else that is in your possession.

How it works:
The NES controller only needs 5 wires to function, 2 being +5 volts and ground. The other three are the key to its communication. One line is a clock line, which pulses constantly. A strobe line is used to signal the beginning of a byte. And the last line is the serial data out, which outputs 1s (+5 volts/high) and 0s (ground/low). Inside the NES is a standard chip, a 4021. This is a parallel to serial convertor.

To start off communication the strobe line is raised high momentarily. This tells the controller to send out serial information. The first bit which represents A is outputed on the serial line. Then the clock signal is raised momentarily which the controller receives and thus it outputs the second bit which represents the B button. If this bit is a 1, then the button is not pressed. If the bit is 0, then it is pressed. The clock signal is once again raised for a moment, and the controller again responds with another bit which represents Select. Once again, if the bit is 1, its off, if it is 0, then it is pressed. This continues for a total of 8 times, and after 8 times we have read the state of every button on the controller. So once again the process starts all over with the strobe line being raised and lowered quickly, reading a bit, then the clock pulsates 8 times while data is being sent out serially.

Here is an example showing all 3 lines used in communication, the B button is pressed because it is low after the first clock signal (2nd bit overall):

This should help you visualize the signal lines being raised and lowered. As stated above, the first bit represents the Abutton, the second bit represents B. The following table is the complete listing:
Bit # (Clock Cycle)Button

The program itself is very simple. It follows the above exactly: pulsate strobe, read bit, pulse clock, read back a bit, pulse clock, read back a bit, etc. Once 8 bits have been read (that makes 1 byte) the program then checks each bit in order raising or lowering the lines as needed. The output is known as active low, which means each pin will be outputting +5 volts until the corresponding button is pressed which will make the line go low (grounded). This will allow us to interface directly to the Dreamcast itself.

Source Code
Hex file for a 16F628A


Interfacing the PIC is quite easy. On the NES connector, +5 and ground is self-explanatory. The serial pin connects to A0. Clock connects to A1. Latch (strobe) connects to A2. The table refers to which pin corresponds to which button:
ButtonPIC Pin

Finally the power needs to be hooked up to the PIC, +5 volts to VCC, and ground to VDD.