Introduction: USB NES Controller With an Arduino!

Picture of USB NES Controller With an Arduino!

UPDATE 22-12-2014
Instructables user mattpbooth has updated the code and is hosting it on github:

Thanks Matt!

UPDATE 03-12-2011

Replaced a println with print (derp).

UPDATE 01-12-2011

Remade all code from scratch.

Remade 'ible code section; Now includes a 'Processing COM port config for dummies'

Ladies and gentlemen, I proudly present 8bit pleasure.. yours for the grabbing! Whether you use GNU/Linux, Mac OS X, or Windows the USB NES controller is compatible.

Will this in any way alter the controller?

Nope, the controller will stay the same so you can still use it on a real NES

But I don't have an arduino ;_;

You can use the parallel port:

Buy an arduino:

Or a retrozone NES kit:

Step 1: Ingredients for Some Awesome Controller Soup

Picture of Ingredients for Some Awesome Controller Soup

You will need:
A NES controller
An Arduino
A USB cable type B
Something you can use as a Casing
and some wire..
Optional: NES port

Arduino software

Step 2: How to Connect the Arduino to the Nes Controller

Picture of How to Connect the Arduino to the Nes Controller

With some wire connect the pins according to the texts on both pictures..
You could also use the controller port from a NES (a broken one, don't waste a working one).

You want something vaguely similar to the last picture.

Step 3: Code

UPDATE 22-12-2014

Instructables user mattpbooth has updated the code and is hosting it on github:

Thanks Matt!

Hey guys, I've completely rewritten the code and it should work now flawlessy.
The only adjustment you might need to make is to the Processing Sketch; you need to adjust which COM port it should use.
To do this please follow these steps carefully!


1 ) Disconnect the Arduino if it's connected.
2 ) Run the Processing sketch, it WILL(!) display an error.
3 ) Check the console (black box with text at the bottom of processing)
4 ) In the console will be a list of active COM ports;

Serial list
WARNING: RXTX Version mismatch
Jar version = RXTX-2.2pre1
native lib Version = RXTX-2.2pre2
[0] "COM3"
End of serial list

5 ) As you can see currently COM3 is active and is the first COM port at the moment (denoted by "[0]")
6 ) If the Processing sketch ran without displaying an error, press the stop button.
7 ) Hook up the arduino.
8 ) Run the Processing sketch again.
9 ) Check the console for active com ports;

Serial list
WARNING: RXTX Version mismatch
Jar version = RXTX-2.2pre1
native lib Version = RXTX-2.2pre2
[0] "COM3"
[1] "COM5"
End of serial list

10 ) As you can see COM5 suddenly appeared in the list after we connected the arduino.
11 ) We now know that the arduino has COM5 and is the second COM port (denoted by "[1]")
12 ) We know adjust our code;

arduino = new Serial(this, Serial.list()[?], 9600); // ATTENTION!!!

arduino = new Serial(this, Serial.list()[1], 9600); // ATTENTION!!!

13 ) Save the program.
14 ) Load the arduino sketch unto the arduino.
15 ) Start the Processing sketch!

Step 4: Making a Case

Picture of Making a Case

Let your imagination run wild!
I put my arduino into an old printer adapter I found and I think it looks pretty good =)
I did this by gutting the adapter and only saving the 'nipple'.
I removed the 'nipple' from the cable by cutting into one side with a knife, after which the original cable could be pushed out and replaced by my USB cable.

The adapter had a small hole (which I used for the usb cable) and a big hole which I used for the NES controller.
The big hole however wasn't big enough so I cut some away with a saw (very sloppy) after which it was too big, I temporarily fixed this by putting some sticky tape around the controller plug.
I've currently ordered a broke NES to harvest the controller port from in order to make it more.. sexy.

Step 5: It's Alive!

I currently don't have a camera at hand so here is a short desktopmovie of me bashing some buttons on the controls.
If you get an error file saying java wasn't found you'll need to install it (again)
In case anyone is wondering why I made a batch file; I was too lazy to reinstall java and made a small manual fix.

to play a NES game on your computer you will need an emulator:

[windows] (If you're running vista, use FakeNes)

And you will need some games(ROMS) ofcourse but these are illegal to download (Yes, even if you own the original) so whatever you do don't download them and especially not from this site because that one is the most illegal of all *GASP*

Step 6: Additional Info

Picture of Additional Info

More details
Inside the NES controller is an 8bit shift register.
By putting the latch pin high for a few microseconds I'm telling the chip to start spitting data at me.
When it does this, the first byte becomes available to read over the serial pin.
If I want to receive the next byte I'll have to set the clock pin high for 200 microseconds.
I need to 'flash' the clock pin 7 times to get all bytes

Latch high
Wait 200 microseconds
Latch low
Read serial
Wait 200 microseconds

Repeat 7 times
Clock high
Wait 200 microseconds
Read serial
Clock low
Wait 200 microseconds

SNES controller
The code I've written can also be used with a SNES controller!
If someone makes a request I can expand this 'ible to also show how to do that

Original code'

and finally..
This is my first instructable, so go hard on me =P (yes hard, not soft =P)


Experimentonomen (author)2012-07-08


I tried this today and it works but i cannot get a response outta the A button and i've tried both my NES controllers.

I have a hard time believing that the same button on both my controllers are broken, especially since my NES never saw much use.

So i'm leaning on an error in the code somewhere, i'm not a programmer and thus have no knowlefe in this stuff, so debugging is out for my part.

Hey, see the reply to Andromorfo above. Your A is first in the cycle and was being skipped with the first clock pulse.

WilliamW24 (author)mattpbooth2015-06-13

I have leonardo set to press keys like makey makey and it works fine
On everything but emulator
I don't want to use controller I made foot and fist pads but it won't work on emulator please help

lewsidius (author)2011-12-01

thanks for the update and quick reply
i got an error code right away and on this line
import processing.serial.*;
am i doing something wrong
sorry im a newb

lewsidius (author)lewsidius2011-12-16

still getting error messages and wsalgklgkwsaklgwsalgwsalgklgkwsaklgwsalgwsalgklgkwsaklgkwsaklgws
when trying to use the controller

mattpbooth (author)lewsidius2014-12-20

Hey, those keystrokes are down to the keyboard emulator doing its thing. The processing script was reading a string as individual char at the version I used so was firing text like the above when not touching the buttons. If you swap the Serial communication to use a single byte each time (8 inputs = 2^8 = 256) by using Serial.Write/Serial.Read you'll also save 2 bytes per message and have a fixed message length.

WilliamW24 (author)mattpbooth2015-06-13


Videoscope (author)lewsidius2015-03-22

Hey lewsidius did you fix that wsalgllgkwsaklg thing because I'm getting it too

WilliamW24 (author)2015-06-13

I have pins set to print letters on keyboard how can I use this to play games on emulator
For some reason the arduino key presses aren't registering

Ashleyv3 (author)2015-04-23

I would also like to see this include the SNES controller. It's a far easier way to attach a controller to an Ardiuno Uno than building a HID controller.

Videoscope (author)2015-03-22

Please help I got everything hooked up and ready and was ready to play some childhood nes games with the real controller instead of a keyboard but all of the sudden it just started saying wsalglgk just like lewsidius and I don't know if it's hooked up wrong or something please help

Videoscope (author)Videoscope2015-03-22

Also forgot to say I'm using the arduino uno

Andromorfo (author)2012-01-04

Hey man thanks for the instructable, i used the NES controler to control my robot arm, but for some reason the button A doesn`t work, and i`ve tested it with different controlers.

here is a video of my robot arm

P.D.- sorry for the awful english :P

Andromorfo (author)Andromorfo2012-01-06

i changed some of the arduino code and now it works with all the buttons, i needed to read the first bit before the for cicle and then read the others 7 bits

here´s the code, i hope it helps someone getting the same problem

void ReadNESjoy() {
for (int i = 1; i < 8; i++) {

Doesent work!

Just throws a buncha error messages like "nes not declared in this scope" among other things.

This worked for me:

void ReadNESjoy() {

for (int i = 0; i < 8; i++) {
output += dataread * (1 << i);
Jeanot1314 (author)2013-09-30

Hi again,

I made it with an atmega standalone inside the nintendo, so i can plug two remote. I used the usbkeyboard librairie but i still have a tiny problem... When i print letter on a txt everything work fine, but on a emulator it seem that the flow of data is not good. My mario is almost not moving at all, and he make very small jump when i keep press.
I tried to configure a "repeat delay" and a "repeat rate", but the result is still the same. I don't anderstand how your usbjoystick library send the data to the computer, do you know any configuration to do about that?


Prodigity (author)Jeanot13142013-10-02

Hi Jeanot1314,

Could you show me the code you've written?

Jeanot1314 (author)2013-09-24

thanks for the code ^^ To simplify i tried with the serial reading without processing. This work on actual version of arduino.

void loop() {
output = 0;

void ReadNESjoy() {
output += dataread * (1 << 0);
for (int i = 1; i < 8; i++) {
output += dataread * (1 << i);

If you replace the loop and the setup in the program with this, you can see directly the value in the Serial Monitor. All the buttons are fonctionning, it s necessary to read the first time before the first clockhigh.
THanks again, and now lets play!!!! ^^

incognito0288 (author)2013-07-31

you should use an arduino nano and ditch the power cable. it would be smaller and less bulky.just a thought. ..good ible

scewy (author)2011-12-22

This does not work for me, i get the following error-message whilst trying to upload to my Arduino UNO:

The "BYTE" keyword is no longer supported.

ArduinoSketch.cpp: In function 'void loop()':
ArduinoSketch.pde:-1: error: 'BYTE' was not declared in this scope

As of Arduino 1.0, the 'BYTE' keyword is no longer supported.
Please use Serial.write() instead.


Any ideas of how to fix this issue? //John

NondoX (author)scewy2012-07-06

i had the same error.
i think its because you/we are using a newer version of the arduino program

i just installed an alpha version and all worked fine.

give that a whirl.

wilson309 (author)2012-02-08

the processing sketch went fine and it uploaded to arduino board fine but what do i do after i select the proper port and upload onto arduino board? im confused because i open my emulator and a joystick isnt showing up nor will pressing buttons on the nes controller assign keystrokes? connections are solid and it's wired correctly and used the above codes. much help is needed ive been trying to do this for 2 days now (1st arduino project) PLEASE I NEED HELP!!!

hoffsta (author)2011-12-13

I for one would like to see you update this to include support for SNES controllers. I'm new to Arduino, would it be possible to build 2 NES ports and 2 SNES ports simultaneously on one Arduino?

I'm working on a multimedia project that would be running 24/7 and have both NES & SNES emulators available. It would be great if a user could just plug in the appropriate controller and get started without any other configuration.

Another noob question: If I have 2 NES ports and I plug in two controllers, will the "player 1" and "player 2" identities remain bound to the ports (so I can have it just like a NES, player 1 on left port, player 2 on right?)

Thanks for all you work on this! Totally RAD!

chibiturtleboi (author)2011-12-08

It might just be me but I can't seem to find the code anywhere in this guide, any ideas? :/

Prodigity (author)chibiturtleboi2011-12-09

Apparently something went wrong when I reupdated the code, sorry for the inconvenience. It has been uploaded now :O

chibiturtleboi (author)Prodigity2011-12-09

Cool, thanks much!

TechDante (author)2010-10-27

hey how easy is this to multiply the numer of controllers that can be conected

Prodigity (author)TechDante2011-12-01

Very late reply:

Quite easy, the clock and latch from the arduino can be connected to several controllers. You only need one seperate data line per controller.
Some code adjustments need to be made, but my guess is that you can probably hook up to 16 controllers to an arduino duemilanove and even more to an arduino mega (WHY???!!!!!).

How many controllers are you interested in hooking up?
(that is, if you still are interested lol)

olskool (author)2010-02-14

Hey Prodigitythanks for this, it's awesome!
I have one question and one suggestion. The suggestion is to update the code so it has the revised buttons = "this should w0rk... line in it. I struggled with that until I eventually read all of the comments.

The question is: in the arduino code it looks like you are sending a 'z' at the end of the x/o pattern, but it looks like processing doesn't look for it. Currently I get the wrong buttons pressed unless I reset the arduino by re-uploading the sketch.

Is there a way to look for the 'z' in processing so that the buffer doesn't ever slip out of sync?

Thanks for this instructible! I'll be back to post my results when I am finished!

olskool (author)olskool2010-02-14

I think I figured it out. Here's the code. It goes in at the end.

"buttons = NESjoy.readStringUntil('\n');"

It's the Until('\n'); that does it. It looks for that to signal the end of the transmission. Thanks for putting all of this info up!

Prodigity (author)olskool2011-12-01

Hey olskool,

Remade the arduino and processing code completely. (2 million years later lol)
I'm quite happy with the arduino code but the processing code might still need some changes..

Prodigity (author)olskool2010-02-16


Sorry for not responding, I haven't been on instructables for a while.
You're right, I should update the code.. I will get round to it as soon as I'm motivated x'D
As for the additional code, I will implement it and mention you on my 'ible.
Thanks for showing interest in my 'ible =D


lewsidius (author)2011-11-28

I got it resonsive to the nes controller.exe file :( minus the start button )
but how do you get it working with emulators??? do you need a driver?

Prodigity (author)lewsidius2011-12-01

Hi Lewsidius,

I've currently updated the code, you might want to try the new code (it should work much better).
The program reads the messages the arduino sends and emulates a keyboard, so you don't need drivers.
In order to configure the controllers, you simply follow the same steps you would to map controller buttons to keys except you press the buttons on the nes controller.

For FCEUX e.g.

Config > Input
[Port 1] Configure
[Virtual gamepad 1]
Press the up button in the program, press the up button on the nes controller.
Repeat for every button.

kribbyy (author)2011-03-27

I ported this code to work with an SNES controller using an Arduino Uno, and updated the graphical interface accordingly. If anyone's interested give me a shout.

and grampafish: Check out the two lines kiwimonk posted below.

devicemodder (author)2010-12-22

How do I get processing code to work it saysrobot cannot be found

kiwimonk (author)2010-04-13

Awesome Work!  Now I finally have my NES controllers working on a PC!
I was having trouble with the 'A' button (not working)  for a while, and thought it was my Seeeduino.  Read up on the controller spec..   After moving
line 38: digitalWrite(latch1,LOW);
just below line 46 everything worked!

I also had to place these imports into the Processing Script:

import java.awt.Robot;
import java.awt.AWTException;

After I got it all working I modified the code a bit to support two controllers.  If anyone is interested, let me know ;)

Thank you to you and

ElvenChild (author)kiwimonk2010-08-30

I WANT THAT CODE!!!!!!!!!!!!!! please.

kiwimonk (author)ElvenChild2010-08-30 Enjoy ;)

ElvenChild (author)kiwimonk2010-08-31

could you please upload it on rapidshare I can not access megaupload

kiwimonk (author)ElvenChild2010-08-31

ElvenChild (author)kiwimonk2010-08-31


technoguy94 (author)2010-04-28

You do know you can buy USB NES controllers online, right? [link]

Prodigity (author)technoguy942010-04-28

Yeah, those controllers brought me on the idea.
More specifically this website:
(though it's more fun to make it yourself :P)


60829 (author)2010-04-26

 One question, could i do this with a light gun?

Prodigity (author)608292010-04-26

Ehm, I haven't tried this myself but it should work assuming the emulator supports it and you use a crt/tft/tv screen.
LCD screens won't work due to light decay and screen response, though some newer variants could work (those that support 3d shutter glasses should work).

Good luck and have fun tinkering.

AKA=THE SNOWMAN (author)2010-01-21

awesome. i made a belt buckle out of one of those:)

willrandship (author)2009-11-11

I have a quick hard would it be to add axis support so as to be able to add joysticks? I have several 3rd party n64 controllers with awesome joystick (real potentiometers, not cheap plastic) and I was thinking about making a custom gamepad.

Prodigity (author)willrandship2009-11-11

A bit more difficult I'm afraid.
The N64 controller has a completely different protocol,
I did a quick google and came up with this:
Not impossible, but you'll have to start from scratch.
(I'll look into it)

About This Instructable




Bio: Semi-Creative Lack of concentration Believes beards are awesome <3 Arduino Willing to help people in need of answers to teh interwebz q's
More by Prodigity:USB NES controller with an arduino!
Add instructable to: