USB NES controller with an arduino!

 by Prodigity
Featured
This instructable has been updated AGAIN!!! 3 December 2011
Replaced a println with print (derp).

This instructable has been updated! 1 December 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:
http://hellalame.com/nes/nes_controllers.html
Buy an arduino:
http://arduino.cc/en/Main/Buy
Or a retrozone NES kit:
http://www.joystiq.com/2004/09/07/how-to-make-a-nintendo-controller-into-a-pc-joystick
 
Remove these adsRemove these ads by Signing Up

Step 1: 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 http://www.parallax.com/Store/Components/Other/tabid/157/CategoryID/32/List/0/SortField/0/Level/a/ProductID/522/Default.aspx

Arduino software http://arduino.cc/
Processing http://processing.org/
1-40 of 71Next »
Andromorfo says: Jan 4, 2012. 12:25 PM
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
http://www.youtube.com/watch?v=Va9D9Fpc5H8

P.D.- sorry for the awful english :P
Andromorfo in reply to AndromorfoJan 6, 2012. 9:24 PM
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() {
nes[0]=1;nes[1]=1;nes[2]=1;nes[3]=1;nes[4]=1;nes[5]=1;nes[6]=1;nes[7]=1;
latchlow;
clocklow;
latchhigh;
wait;
latchlow;
nes[0]=dataread;
for (int i = 1; i < 8; i++) {
clockhigh;
wait;
nes[i]=dataread;
clocklow;
wait;
}
}

Experimentonomen in reply to AndromorfoJul 8, 2012. 6:11 AM
Doesent work!

Just throws a buncha error messages like "nes not declared in this scope" among other things.
Experimentonomen says: Jul 8, 2012. 6:01 AM
Hello!

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.
scewy says: Dec 22, 2011. 1:41 PM
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 in reply to scewyJul 6, 2012. 8:54 AM
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 says: Feb 8, 2012. 9:26 PM
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!!!
lewsidius says: Dec 1, 2011. 9:31 AM
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 in reply to lewsidiusDec 16, 2011. 6:54 AM
still getting error messages and wsalgklgkwsaklgwsalgwsalgklgkwsaklgwsalgwsalgklgkwsaklgkwsaklgws
when trying to use the controller
hoffsta says: Dec 13, 2011. 8:05 PM
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 says: Dec 8, 2011. 10:54 PM
It might just be me but I can't seem to find the code anywhere in this guide, any ideas? :/
Prodigity (author) in reply to chibiturtleboiDec 9, 2011. 9:15 AM
Apparently something went wrong when I reupdated the code, sorry for the inconvenience. It has been uploaded now :O
chibiturtleboi in reply to ProdigityDec 9, 2011. 11:38 AM
Cool, thanks much!
TechDante says: Oct 27, 2010. 4:10 PM
hey how easy is this to multiply the numer of controllers that can be conected
Prodigity (author) in reply to TechDanteDec 1, 2011. 8:15 AM
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 says: Feb 14, 2010. 8:41 AM
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 in reply to olskoolFeb 14, 2010. 1:44 PM
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) in reply to olskoolDec 1, 2011. 8:05 AM
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) in reply to olskoolFeb 16, 2010. 6:23 AM
Heyz,

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

Greetz,
Joshua
lewsidius says: Nov 28, 2011. 5:41 PM
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) in reply to lewsidiusDec 1, 2011. 7:58 AM
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.
Done!
kribbyy says: Mar 27, 2011. 8:46 PM
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.
grampafish says: Dec 22, 2010. 11:36 AM
How do I get processing code to work it saysrobot cannot be found
kiwimonk says: Apr 13, 2010. 4:18 AM
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 in reply to kiwimonkAug 30, 2010. 8:24 AM
I WANT THAT CODE!!!!!!!!!!!!!! please.
kiwimonk in reply to ElvenChildAug 30, 2010. 11:48 AM
http://www.megaupload.com/?d=KDTY05VX Enjoy ;)
ElvenChild in reply to kiwimonkAug 31, 2010. 7:02 AM
could you please upload it on rapidshare I can not access megaupload
kiwimonk in reply to ElvenChildAug 31, 2010. 12:15 PM
http://rapidshare.com/files/416302296/NESpad_2_Controller.zip
ElvenChild in reply to kiwimonkAug 31, 2010. 1:07 PM
thanks
technoguy94 says: Apr 28, 2010. 5:50 AM
Cool!
You do know you can buy USB NES controllers online, right? [link]
Prodigity (author) in reply to technoguy94Apr 28, 2010. 9:35 AM
Yeah, those controllers brought me on the idea.
More specifically this website: www.retrousb.com
(though it's more fun to make it yourself :P)

Greetings,
Prodigity
60829 says: Apr 26, 2010. 8:03 AM
 One question, could i do this with a light gun?
Prodigity (author) in reply to 60829Apr 26, 2010. 9:35 AM
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 says: Jan 21, 2010. 2:09 PM
awesome. i made a belt buckle out of one of those:)
willrandship says: Nov 11, 2009. 8:58 PM
I have a quick question...how 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) in reply to willrandshipNov 11, 2009. 9:47 PM
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:
www.mixdown.ca/n64dev/
courses.cit.cornell.edu/ee476/FinalProjects/s2002/jew17/lld.html
Not impossible, but you'll have to start from scratch.
(I'll look into it)
willrandship in reply to ProdigityNov 12, 2009. 7:26 PM
So, your project just takes input from the controller's plug itself? I was thinking of having buttons that hook in, not the n64 controller itself. The only reason I mentioned the n64 was because I have a few with good joysticks I intend to strip out. My question was how hard it would be to add joystick output for the computer.
Prodigity (author) in reply to willrandshipNov 12, 2009. 11:27 PM
Hmmm well I've had a look.. seems to be difficult both ways.
The original N64 controller uses photocells and LEDs (like an old mouse) to read the 2 joystick positions.
I've have no experience at all with this, but you might be able to rip one of the controllers out of a mouse and let it decode it.

I'll have a better look into it.
willrandship in reply to ProdigityNov 13, 2009. 7:13 PM
Umm, I think you misunderstood. In this third party controller, the joystick really is a potentiometer. i just want to know how much modification is required to the program to use axises, from the serial transfer end. I am not concerned about hooking up any type of controller, but something similar to the input shield, but customisable!
Prodigity (author) in reply to willrandshipNov 14, 2009. 1:23 AM
Woops, my bad. '-_-
My program cannot be used at all (neither the arduino code nor the processing code) regardless of whether you use the plug side, or directly connect the arduino to the buttons and joysticks themself.

If you could supply me with the resistances of the potmeters I could however make a sketch for you on how to implement them.
1-40 of 71Next »
Pro

Get More Out of Instructables

Already have an Account?

close

PDF Downloads
As a Pro member, you will gain access to download any Instructable in the PDF format. You also have the ability to customize your PDF download.

Upgrade to Pro today!