loading
Hello!

In this instructable, I will show you how to hook up a Nintendo Entertainment System control pad to an arduino, the arduino is in turn running a special sketch that allows it to show up to a PC as a USB HID joystick!

And if that is not cool enough, I will show you how to shove it all inside the NES controller shell for a simple controller + wire, "plug n play" device!


Notice!!
If you hook this up wrong you can fry your arduino, and or your usb ports, if you choose to biuld this project you assume responsibility for its proper construction

Sofar I have tested this on ... Windows XP pro, Windows 7 64 bit, and Ubuntu 9 32 bit

So far its not tested on Mac, I don't see why it should not work on Mac, but its untested, the only Mac I have in the house is a SE from 1986, I will test it as soon as possible, just gotta sweet talk a co worker into bringing his macbook pro into work :)

Step 1: Parts N Tools

Tools: your usual electronics tools... on this project I used

Soldering Iron

Solder wick

Solder

Small phillips (+ shape) screwdriver

razor knife

small needle nose pliers

electrical tape (or proper sized heat shrink, I just happen to be out)

multimeter

Tweezers

Parts:
Arduino (with atmega 168 or 328, other chips not tested)

and a EXTRA atmega chip, you dont HAVE to but I installed this inside the controller, so you may want to have an extra chip on hand with a boot loader installed on it to replace the one we will be using (especially for me since I use my arduino AS a avr programmer, I would be kinda stuck)

16mhz crystal (ceramic resonator works fine, but I had the crystal and caps already)

2 * 22pf for the crystal (if your using a resonator then its packaged in for you)

0.1uf cap (code 104)

2 * 68ohm 1/8 watt resistors (or smaller if you want, just not larger, its tight in there)

1k5 ohm resistor

2 * 3.6v zeiner diodes 500mw or smaller

USB cable you dont mind cutting one end off of

NES game pad

thin insulated jumper wire

Step 2: Software

I am not smart enough to figure half of this usb stuff out, so were using a library, In researching this on good old google, I found http://www.arduino.nl/?p=36

Now there is a couple things to note on this page

1) its based off of the usb keyboard library found on rancid bacon
http://code.rancidbacon.com/ProjectLogArduinoUSB, which REQUIRES arduino 0016! I have messed around with this for a few days trying to get it to compile on arduino 18 software, and though it wants to work the computer never can communicate with the device, leaving a ugly balloon next to my clock, the joystick library flat out does nothing on 18

arduino 16 started to be a pain in the butt, and not start up for me, what I figured out is I needed to remove the preferences.txt file that 18 had placed in my user folder, and then start arduino 16, it should work, and 18 continues to work off of 16's file

see http://www.arduino.cc/en/Hacking/Preferences so see where you can find yours if you need too

2) The comments of the joystick library page state that it doesn't compile, and it doesn't, its not that hard to fix, and I already have in the software download. But if anyone else wants to know ...

in UsbJoystick.h you need to include interrupt.h with the other 2 includes, and change line 105 from...

void sendJoystick(byte val0, byte val1, byte val2, byte val3, byte val4 , byte val5 , byte val6, byte val7) {

to

void sendJoystick(uchar val0, uchar val1, uchar val2, uchar val3, uchar val4 , uchar val5 , uchar val6, uchar val7) {

Finally, after fiddling with this library for nearly 2 solid days, I gave up on changing its configuration, so the computer sees a 6 axis 4 button joystick, even though it only responds to 2 axis and 4 buttons


Moving on, down below you will see 2 files, the zip file contains the fixed usbjoystick lib, place that in the /hardware/libraries folder of arduino 16, and my project files, open the pde file in arduino 16, compile and upload

otherwise if you have a avr programmer handy and dont mind dealing with avrdude there is also a hex available

Step 3: Hardware Time

Ok, once you have the software uploaded to the chip you can put the arduino on the side for a little while, and get rid of that pesky computer keyboard

We will test the controller connected to the arduino In a little bit, but first we need to make some changes to the controller itself

Flip your controller face down on the table, using your small + screwdriver remove the 6 screws, the back and the controller board

... Apparently I am missing a picture, but place the controller shell / screws / buttons / pads in a safe place, and desolder the controller cable and its shift register IC

Once you have those 2 items out of the way (keep the shift register, its fun) clean and (re)tin all the pads

Most designs use the shift register to talk to the controller, as its a simple 3 wire device, but I had a rather large chip with (still) a lot of I/O pins, and a rather hard time finding a place for it AND another 16 pin dip chip, So I said ok and we are going to wire each button directly to a pin of the microcontroller

In order for this to work we need to know which pads go to what parts of the controller

Step 4: Testing

I highly recommend that you spend the extra time and hassle to hook up 10 wires to the nes pad and plug them into your arduino board and make up the usb ciruit

A note about usb cables, or any other cable, don't trust the colours, use a meter to find out which wire goes to each point on the plug, in my case the wires are not even the correct colours so it does not matter, but I have also had a keyboard that had wrong colours and wrong printing on the pcb!

Connecting the controller is tedious, the usb hardware is easy, either way its good to know it functions, cause after this its pretty much the point of no return

SO TEST IT

Take note that the cathode of the diode (the end with a stripe) needs to face into oncoming current, and the anode needs to be connected to ground

this is backwards from most diodes, what is happening here is the zener diode has a very low reverse breakdown point, so it "leaks" a controlled amount of current backwards through the diode to ground, which also drops our voltage down to the 3 ish volt signals expected by usb

Step 5: Verified Working

So we have hooked up the circuit plugged it in, verified it working by checking the control panel or maybe playing Mario for 20 min , but its time to move this fragile bundle of wires into its new home.

Doing so requires some pain in the butt soldering, but really its not hard (fiddly yes). The trick is to tin both parts, then using your tweezers hold them together and melt the solder to form a solid joint

for practice try soldering components leads together, as we will be doing that too

Start off by cleaning the game pad's pcb of all wires(again) and carefully remove the atmega from the arduino.

Step 6: Construction: the Atmega

Using your needle nose pliers you need to very carefully bend the following pins of the microcontroller out at a 90 degree angle, right at the base where the pin gets fat.

Pin

1     28      
2     27
3     26
4     25    
5     24
6     23
7     22
8      -
9     20
10    -
-       -
-       -
-      16
-      15

the pins marked with a - leave pointing down, these will fit into the original shift register "socket"

The pcb has a silk screen of which way the sr went in, line up the atmega where pin one is on the same side as indicated on the silk screen (facing the cable connection), and where the lasts pins are in the next to last set of holes

Step 7: Construction: Start Hooking Things Up

First flip the board over and solder only where the atmega pins are poking through the pcb, we just connected 6 out of the 8 buttons yay, we still need to connect buttons A and B

Get a segment of jumper wire, tin the end, get a (not excessive) ball of solder on the nes pad 15, do not push the wire through the hole, just solder it flat on the pad

Now loop it around so it meets up with pad #12, Pin # 17 of the atmega is already in this hole, and the pad is not connected to anything else in the controller, so B button is good to go, A was not as graceful

For button A solder a wire flat onto pad #1, loop this around to the top of the board and solder to pin # 23 of the atmega

Also solder blob pins 20 and 21 together (dont overheat) this is aref and analog power supply, aref is soldered to the pcb's +5v bus


Step 8: Construction: Adding Power Lines

Every Nintendo controller I have seen was kind enough to have a couple extra pad's and holes made connecting to power and ground, its a great place for a decoupling cap, so lets add one

Insert your 0.1uf cap into the top of the pcb, fold it over so it lays flat, and away from the screw hole in the corner, flip the board over and solder its leads to the pads, but do not clip the leads short yet

Now solder 2 jumper wires to those pads (I could have done this differently but hindsight is 20/20) for ground and + 5v, now you can clip the leads of the capacitor

Wrap the power and ground jumpers to the top of the board, connect +5v to pin 7 of the mega, and connect ground to pin22 of the atmega

Step 9: Construction: Crystal Time

The crystal is going to be sitting sideways, to make life a little easier you may want to "smoosh" the leads down so they line up with the atmega's pins easier, Also I put the board back in its front shell, there is a post right where the crystal goes, so you have a choice, you can work around it, or cut the post off

I choose to work around it (thinking its more protection for the crystal if this gets stepped on)

Solder 1 leg of the crystal to pin 9 of the atmega, bend the other leg to pin 10 of the mega, now we can add the 22pf caps, they are necessary for operation

The first capacitor is pretty, easy, stick one lead into that leftover ic hole (pad# 8) and solder to the pcb, solder the other lead to the closest lead of the crystal

The other capacitor is a little bit of a pain in the butt, because of a second plastic post, you can cut this post off too if you wish, but I worked around it, One lead of that capacitor needs to be soldered to the second lead of the crystal, and the second lead of the capacitor needs to be soldered to pin #8 of the atmega (this is a ground pin)

Step 10: Construction: Resistors

With the basics needed for the microcontroller to run we can hook up the resistors that are the first step in our level conversion from 5v to ~3v

First resistor to hook up is the 1k5 resistor, insert it into the top hole of where the cord used to plug into, solder it in place from under and just kinda bend its lead out of the way for now

Side note, I say 1.5k and picture a 1.0k, reason for this is I already have 100 3.3v diodes, and with the currents involved its only pulling the line up to ~2.7v instead of 3.3, this may be fine for my mutt open architecture computers but not all computers will "play ball", use 3.6v diodes and a 1.5k ohm resistor and when you do the math its around 3.2+ and will not cause issues with computers that dare things to be within spec

Now Take your 2 68 ohm resistor and solder a end to pins 4 and 6, trim their leads so they stagger a little at the opposite end and bend those leads to the right

Finally for this step add some jumper wires to the 3 resistors and clip them so they all end at the same place (I used red for the pull up resistor, and blue for the 2 data lines

Step 11: Construction: USB Cable (nearly Done)

Take the wires that lead from the pull up resistor (1k5) and one of the 68 ohm resistors that ultimately ends up on the mega's pin 6, and pigtail them together.

Also take the wire lead from mega pin 4 then strip and twist its end

Next take your diodes, and pigtail their cathodes (end with the stripe on it) to the other wires

Find the D- line in your usb cable, Mine was brown ... anyway do a inline splice with the pigtail that contains 2 wires and the diode, then solder together and wrap in tape, take the D+ line and splice it with the other wire that is coming off of the mega's pin 4 and the diode, solder them all together and wrap with tape

You should have the other leads of the diodes still sticking out, choose whichever one looks longer and solder it to the lead of the capacitor that is connected to ground (the other side would be connected to the crystal), then solder the other diode lead to the first diode lead so they are both connected to ground

Then solder the ground lead from the usb cable to one of the leads connected to ground

Step 12: Construction: USB Cable and Wrapping Up

The final connection is for the usb to provide everything with power, I was running a little tight on space, and really did not want to run another jumper wire... what to do?

Easy, cheat, plug the USB's +5 line into the last IC socket hole on the top of the board, this only goes 1 place, and it ends up right next to where we connected the pull up resistor, to power the rest of the board, we need to jump the first 2 pads where the cable used to attach

Wrapping up:

Plug it in and test it one more time, I added some glue on spots that I thought could bend easy or vibrate and you should too, although I am impressed with the NES controller strain control, I started bending plastic and the cable did not  budge

Take this chance to really clean your controllers case, so you don't have old goo stuck between the buttons and the shell

As you put the controller back together there are supports in the back half of the shell, if you followed the pictures there should be little issue, just kind of peek inside as your closing up and do not force pinch anything, it might take a little poking to get everything happy

And most importantly enjoy!


<p>Hello there and thanks for the Tutorial!</p><p>Do you think this could be applied to a Arduino Nano V3 Clone, too, if it has the bootloader installed? I want to turn my Clones into USB HID for using them as Gamepads. I would appreciate every help i could get.</p>
<div>Forgive-me, i'm very,very late. <br><br>Hello friends ! someone could give me a hand? this is a very good tutorial! but unfortunately there are some things in my opinion, are not very well explained. Would someone help me? <br><p>First, the breadboard layout is impossible to understand why one of Zenners diodes, it's positive rail ! all rectification project with this type of diode, inserts it into the ground rail. And more: one of the diodes you can not see where it fits, if it is on the ground or in the positive rail.</p>Second, despite the high quality of the photos, I can not understand the soldering parameters in a good way. And for now, i'm just wanna test in Arduino.<br><br><p>Third, the issue of 1k5 resistor. I know the tutorial already has a few years, I am Brazilian and in my country everything is &quot;late&quot;, despite the internet (really). More recent projects such as the &quot;V-USB for Arduino&quot; 2K.2 use of resistors for emulation of mouse and keyboard. I myself can successfully tests using 2K.2 resistor. When 1K.5 use, the device is not recognized. Why 1K.5 resistor ?</p>I use an Arduino UNO R3 board, MCU Atmega328p, my IDE is 1.0.5 R2 (tried installing the &quot;0016&quot; Suggested by the author: impossible for me) and my operating system is Windows 7 64-bit. Despite my IDE differ from suggested, it works perfectly with other USB device tests, such as &quot;mouse&quot; and &quot;keyboard&quot; &mdash; remember that I use the resistor 2k.2 and not the 1k.5.<br><br><p>The intention of the author of this post tutorial was great and I thank you very much. But these doubts remained. What I really wish is: someone could send me the schematic right of breadboard with Arduino and if possible, all that is compatible with my IDE? or someone could send me a new USBJoystick library also compatible with my board and IDE, in the case of not being able to meet the first request ?</p><p>My email is audiogamers@gmail.com. </p><p>Thank you all for reading this huge text I wrote and once again, I apologize because i'm very late in this instructable, where everyone seems to have obtained accomplish the project successfully. Forgive me. </p><p>Greetings!</p><br><br> <br></div>
The first link on the software page doesn't seem to work any more. :(
Building an nes multi platform emulator using the nes shell, Need to know if i can drop the Arduino in the nes and plug multiple controllers into the Arduino. I.E. Arduino plugs into mini itx via usb, two nes controllers plug into Arduino via nes controller port. Will this be possible?
Hi ! I've been trying to get this to work for a few days now. I managed to get the code to compile using Arduino 0016, but as some people already pointed out, the schematics doesn't look like the wiring diagram... and none of these are actually working for me. The computer sees an &quot;Unknown USB device&quot; under Windows, and lsusb doesn't return anything on Linux. <br> <br>I've been trying to go back and use the wiring of the UsbKeyboard project, but using the UsbJoystick library with it doesn't work at all. The documentation of the UsbJoystick library doesn't mention the wiring explicitelly, and the originl website seems to be down. <br> <br>I'd love to have some additionnal informations, at least for the wiring.
Tried on windows 8 64 bit. so far only gotten it to show up as an unknown VMWare usb device and on a friends vista 32 bit an unknown usb device. no HID usb joystick yet :(
Awesome tutorial!
1.5k resistor ... 1/8 watt, 1/4 watt, 1/2 watt? 1 watt???
whatever you have, I used 1/8th watt 5% tolerance
Hi! I'm having some trouble understanding the schematics here, it seems to me that they are showing quite different setups? And I can't find an arduino pin 14 either?<br>
I double checked, they are showing the same thing, but the breadboard layout makes it look harder than it is<br><br>also digital pin 14 is analog pin zero (d15 is a1 etc to 19)
I've looked at this as well and agree with kirrebona. In the two schematics arduino pins 2 and 4 are not going to the same place. In the bread board you have pin 2 going to D+ and pin 4 going to D-. In the other pic you have them reversed. I might be wrong but I do not want to follow the wrong one. Some imput would be great thanks.
Yep, the breadoard image and the schematic image apparently have pin 2 and pin 4 reversed. I'm not sure which is correct (or where in the code/library those pins are chosen in the first place). Also, the diode on pin 4 in the breadboard image is connected to power, rather than ground. Please clarify the pin4/pin2 connections.
This is great, but a little out of my comort zone for electronics. Any chance you would be willing to sell one? Thanks!
heare this is beter for you http://www.retrousb.com heare is a you thbe video of it http://www.youtube.com/watch?v=vG_OOV2bBaY
Check E-Bay. They should have some good ones for a low price :)
How much is the cost of this Usb NES controller?
Hey nice Instructable! :)<br>I'm wondering if it's possible to get 2 NES controllers with one Atmega328 via one usb hub?
yea it would be pretty easy if you left the original chip in the nes controller, and chained them together, as the original puts out a easy serial stream
so all I need is a serial to usb converter? :D<br>I though about putting the Atmega chip and the circuit &quot;behind&quot; the original plugs so you can plug in or out the controller, but didn't want to have 2 USB connection :p<br>Thx didn't knew it gives serial signals ^^
its not RS232 like computers use, its (a simplified) SPI protocol at 5 volt levels, which is real easy to read with a microcontroller to read <br><br>it requires 3 lines, a latch line a clock line and a data line<br><br>you toggle the latch and that signals the controller to read the current button state and store that in the shift register, then you send it 8 clock pulses to read each button state one at a time serially <br><br>
cool thx a LOT! :)<br>I thing this would be really helpfull to others to, maybe I'm gonna do a instructable about it ^^
I mean, it would be easy to just add some lines of codes to give the Atmega328 the pins where the second controller is connected to, but to be honest, I'm new into arduino programming and don't get it xP<br>Would be REALLY cool if someone could help me with that! :)
Awesome instructable! Now I wonder if we can figure out how to &quot;theoretically&quot; store an accessible library of games (roms) so that it will be accessible through the controller....
you can get a usb 1, 2-3 port hub chip from TI at most resellers that does not take a bunch to hook up, and strip down a flash drive <br><br>loading it would be slow as crap but running from it once loaded would be fine
Can I use an atmega16 instead?
I dont think you can with the arduino lib that I used, but its made out of VUSB which pretty much runs on any avr with 128bytes of ram and a 1b of storage
Can it be done for the SNES to work?
yes as they are pretty much the same, though the SNES uses 16 bits of data for the 12 buttons instead of 8
hey it looks like you are using V-USB, I've developed a MCU kit that is designed specifically to build stuff like this<br><br>http://www.seeedstudio.com/depot/usnoobie-kit-p-708.html?cPath=104_128
not directly, yes it uses VUSB but I am c-tarded and never really got far with the plain lib<br><br>thanks for the link I will check it out!
Would it be possible to modify this project to make a USB joystick using potentiometers and buttons, but not use an NES gamepad at all? Awesome job BTW!
yes you can pretty much use anything you want, though since I am using a lib for arduino and not directly VUSB, and suck at USB descriptors you will have to do some legwork
Hi you might be interested in my tutorials here<br>http://frank.circleofcurrent.com/index.php?page=hid_tutorial_1<br><br>and this will also help<br>http://frank.circleofcurrent.com/index.php?page=usnoobie_rfid_keyboard
May I humbly suggest: http://denki.world3.net/retro_v2.html<br><br>Cheaper than an Arduino (although you do need an AVR programmer, or you can order programmed chips from me or anyone as it is open source) and designed not to alter the original pad. Well, you can reduce cost a bit by splicing in to the pad or do what I do and add a DB9 near the NES connector so it can be used on USB and a real NES.
this is pretty cool check out this website http://www.retrousb.com/index.php?cPath=25
IVe got some 5v zeners any chance those will work?
no the D lines need to be around 3v, some usb systems are 5v tolerant on those lines but its out of spec and could cause damage to your port
I think it would be a lot less invasive to just tap into the shift register. You could even leave it functional for the NES too that way.
also! I have mangled this NES pad so many times with various fun things I thought its time to place something in it and get a new one before pads start ripping off, or screws strip out
I wanted to use a smaller chip, and I may in the future, with the atmega328 in there it seemed like extra hardware right where it would be &quot;sorta&quot; convenient to place that big chip
(nice instructable by the way)
Thanks

About This Instructable

119,238views

233favorites

License:

More by osgeld:Project Advantage: Install a famiclone into a NES Advantage Joystick Spinner / Jog Wheel Inside of a VCR Head No CPU / MCU led pulse-fade 
Add instructable to: