Use an Arduino with an N64 controller

 by quasse
Featured
IMG_7557.JPG
There are tutorials out there for using an NES controller with an Arduino, but using the more complicated N64 controller and its analog joystick has a definite appeal. If you have an Arduino around and don't want to buy an Adaptoid, this instructable will make it possible to play emulated games in Project 64 with your Ardunio and an N64 controller.

Is this hard? / Will it damage my stuff?
This will not modify your controller in any way, and the wiring is extremely simple, so if you do everything carefully there should be no risk to your controller, and you can unhook it at any time to use with a N64 console.

What you will need:
Arduino - $30
Processing 1.0 - free
Arduino Software - free
3 pieces of wire - free (I hope)
USB cable


 
Remove these adsRemove these ads by Signing Up

Step 1: Wiring the controller

plug.png
IMG_7561.JPG
IMG_7562.JPG
The first thing you need to do is connect your Arduino to the controller
The controller only uses three leads: +3.3V, signal, and ground.
Looking directly at the plug, ground is farthest left, signal is in the middle, and +3.3V is on the right. Using the wire, connect ground and +3.3V to the respective pins on the Arduino, and connect the signal lead to the Digital 2 pin on the Ardunio.

NOTE: If you have other code on your Arduino, you should disconnect the controller and upload the new code from the next page to the Arduino before powering it up with the controller attached.

Connect the Arduino
Connect the USB cable and the Arduino will have power.
1-40 of 88Next »
xenoinc says: Apr 12, 2012. 2:44 PM
Great post!

With the new version of Arduion-1.0 i did have to include the "import" stuff & as well take care of RXTX-2.2pre1 / RXTX-2.2pre2 (see below)


Minor Issue:
Has anyone made a patch yet for the controller's sensitivity? With a lot of games this is a HUGE problem.

Overall, great job throwing together the documentation


Fix the RXTX errors:
http://rxtx.qbang.org/wiki/index.php/Download
POSSESSEDFERRET in reply to xenoincMay 11, 2012. 9:15 PM
Hey xenoic, which version do I need to download? And do I need the source or binary?
xenoinc in reply to POSSESSEDFERRETMay 14, 2012. 7:30 AM
Currently they are only offering "RxTx-2.2 pre2". So this should help you out.

just pull back the latest RxTx 2.2 preview version & you should be good
Jdbye says: May 15, 2013. 9:14 AM
I've been trying to get Controller Pak support working, but it seems the timing of the sending/polling isn't accurate enough as getting the controller status and button state works fine (verified this by logging the data) but the mempak refuses to work. I don't know assembly so I can't convert the entire code to it, does anyone have any suggestions for optimizing my code and making timing more accurate?

Arduino code can be found here: https://dl.dropboxusercontent.com/u/8225581/N64_Arduino.rar
Project64 plugin source: https://dl.dropboxusercontent.com/u/8225581/ArduiN64.rar
StudioAfterlife says: Feb 18, 2013. 1:57 AM
Anyone have any luck either getting this to work with Processing 1.5.1 or newer or find a place to download 1.0/1.1?
ozatomic says: Jan 28, 2013. 8:58 PM
Having some problems getting the Processing application to work. I've tried Version 2.0b6 and version 1.2.1 becasue I can find ! and i keep geting the following error about disabling serialEvent. Doesn't have anything about a RXTX missmatch Stable Library ========================================= Native lib Version = RXTX-2.1-7 Java lib Version = RXTX-2.1-7 error, disabling serialEvent() for //./COM2 java.lang.reflect.InvocationTargetException at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at processing.serial.Serial.serialEvent(Unknown Source) at gnu.io.RXTXPort.sendEvent(RXTXPort.java:732) at gnu.io.RXTXPort.eventLoop(Native Method) at gnu.io.RXTXPort$MonitorThread.run(RXTXPort.java:1575) Caused by: java.lang.NumberFormatException: For input string: "" at java.lang.NumberFormatException.forInputString(NumberFormatException.java:48) at java.lang.Integer.parseInt(Integer.java:470) at java.lang.Integer.valueOf(Integer.java:554) at N64_Controller.serialEvent(N64_Controller.java:68) ... 8 more
ozatomic in reply to ozatomicJan 28, 2013. 9:06 PM
Ignore this i had enabled debugging in the ardunio file and forgot to turn it off .
clynch7 says: Jan 17, 2013. 10:15 AM
I've tried searching high and low looking for Processing 1.0, but with no success. Do you have any ideas where I could find it?
Klaudiuszm says: Jan 4, 2013. 6:03 PM
Great instructable! I've used it and it works great. I have found one troubling issue though, the analog stick is behaving like digital(being either on or off).
Klaudiuszm says: Jan 4, 2013. 6:03 PM
Great instructable! I've used it and it works great. I have found one troubling issue though, the analog stick is behaving like digital(being either on or off).
clynch7 says: Dec 26, 2012. 4:38 PM
I don't know if this instructable is still alive, but in the Processing window, it says that it "cannot find anything named "KeyEvent.VK_UP". " I feel like I'm so close to being able to play!
quasse (author) in reply to clynch7Dec 26, 2012. 7:03 PM
I think that over time the processing people have changed the way KeyEvents work, but I remember someone commenting with the changes that needed to be made to the code...

If that doesn't work, you could try and find the old version of processing that I used to write this tutorial. I think it was 1.0
cubbydebry says: Nov 21, 2012. 2:45 PM
Okay so Im having a little bit of trouble working this out on my mac. I hooked up the controller correctly and check out the serial monitor, that seems to be working okay, I get a "4" for pressed, a "0" for unpressed and then the joy stick input, so I think the error is in the processing file. I am using processing version 2.0b6, I added the "import" lines and the only errors I get are:

WARNING: RXTX Version mismatch
Jar version = RXTX-2.2pre1
native lib Version = RXTX-2.1-7
and something about a stale lock file, if anyone has any ideas, your help would be greatly appreciated :)
jlittle17 says: Nov 1, 2012. 4:00 PM
How do you change the controller pin?
I tried changing #define N64_PIN 2 to #define N64_PIN 13, but this seems to do nothing; the controller does not work on pin 13 but it still works on pin 2.

The reason I ask is because I wan't to connect 4 controllers at the same time, allowing 4 people to control 4 controllers.
jlittle17 in reply to jlittle17Nov 2, 2012. 7:32 PM
Well I found out how to change the pin number by changing the 0x04s in these values:
#define N64_HIGH DDRD &= ~0x04
#define N64_LOW DDRD |= 0x04
#define N64_QUERY (PIND & 0x04)

to 2 raised to the power of the pin that you want (so if I wanted pin 4, I would put 2^4 which is 16. Make sure the 16 is in decimal, not hex though.)

However, I want to add multiple controllers. I tried a few ways of doing this by changing numbers around values and stuff around, but what I have tried is unstable (player one always works, two sometimes, but can never go down, three is good 3/4s the time, and I have yet to have a problem with 4.)

Does anyone know how to make the code stably support at least 4 players?
jlittle17 in reply to jlittle17Nov 4, 2012. 5:54 PM
Finally got 4 controllers to stably work, if anyone wants the code and/or help making it work, feel free to contact me... in some way, pming me is probably the best. Thanks so much quasse for the code by the way!
cubbydebry in reply to jlittle17Nov 20, 2012. 4:33 PM
Can you post your code?
jhorcasitas in reply to jlittle17Nov 10, 2012. 5:53 PM
Hi, im very interested in what yoou said, which arduino did you use?
jlittle17 in reply to jhorcasitasNov 10, 2012. 9:43 PM
Sadly, I used the controllers for a little bit, and they started acting up again... I will have to do some more tests and try more stuff out. I am using a Uno by the way. It is really odd since I can see no reason why one controller should affect another and why the code only likes certain controllers in certain slots...
Jdbye says: May 23, 2012. 5:15 PM
I followed this guide and it worked well.
However, I wanted analog stick support, so I wrote a plugin for Project64 and other emulators.
The only thing that's missing is Memory Pak, Rumble Pak and Transfer Pak support (like the Adaptoid has)
I have no idea how to implement either of them and there doesn't seem to be much of help on google, nor can I find the source code of the Adaptoid plugin/driver, so if anyone could point me in the right direction that would be great.
relima in reply to JdbyeNov 2, 2012. 10:45 AM
Please, can you make it available as a compiled file?

The source is very helpful, but I am running into problems when compiling it.

Thanks
quasse (author) in reply to JdbyeMay 24, 2012. 5:55 PM
That sounds awesome, is your plugin posted online anywhere?
Jdbye in reply to quasseMay 25, 2012. 2:14 AM
Oh, also, Rumble Pak support would be pretty easy to add. I would add it if I knew where my Rumble Pak was.
Jdbye in reply to quasseMay 25, 2012. 2:11 AM
Here: http://dl.dropbox.com/u/8225581/ArduiN64.zip
Only one controller is supported at the moment, but adding support for more would be easy. Mempaks work however by letting the emulator handle them (but that means you can't use physical mempaks)
You will probably have to change the COM port in Controller.cpp to match your Arduino's COM port (it's hardcoded for COM4 at the moment, I would add a configuration dialog to choose COM port, but I'm not sure how to make dialogs in C/C++)
natman3400 says: Jun 20, 2010. 6:06 PM
This is so fun to use with my atomic purple controller. The connector broke about a year back, and I haven't been able to use it with my real 64, and have been wanting to use it on the computer.
cdanger in reply to natman3400Oct 15, 2012. 8:51 PM
Just a hint :] ...
If it's an easy 3 wires to hook the controller up to an arduino, it's an easy 3 wires to plug it into your console.
woodmaster says: Jul 1, 2012. 9:06 AM
Hey it´s a verry helpfull instructable, but can you tell me the colours of the cables ( because on my old controller is`nt a plug)????

Thanks woodmaster
abadfart says: Mar 14, 2012. 12:24 AM
im not really familiar with Arduino could you give me an idea of how to hook 4 controllers so i can play 4 player super smash brothers
carlos.camposalcocer in reply to abadfartJun 1, 2012. 6:43 PM
http://www.instructables.com/id/nintendo-64-arduino-2-controllers/ works for two controllers
carlos.camposalcocer in reply to carlos.camposalcocerJun 1, 2012. 6:44 PM
gadgehammer says: Apr 25, 2012. 8:33 AM
Hey which part of the code do u add
"import java.awt.Robot;"
"import java.awt.AWTException;"
"import java.awt.event.ImputEvent;"
gadgehammer in reply to gadgehammerApr 25, 2012. 8:40 AM
btw i am running Processing 1.5.1
POSSESSEDFERRET in reply to gadgehammerMay 11, 2012. 9:13 PM
Add them at the end of the "N64_Controller", and N64_Controller_Mouse" processing programs.
jhawkman4 says: Feb 7, 2012. 9:40 AM
hey quasse, i'm getting this lengthy error when i run either the controller or the controller_mouse pde in programming:



WARNING: RXTX Version mismatch
Jar version = RXTX-2.2pre1
native lib Version = RXTX-2.2pre2
error, disabling serialEvent() for /dev/cu.usbmodem621
java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at processing.serial.Serial.serialEvent(Serial.java:238)
at gnu.io.RXTXPort.sendEvent(RXTXPort.java:772)
at gnu.io.RXTXPort.eventLoop(Native Method)
at gnu.io.RXTXPort$MonitorThread.run(RXTXPort.java:1641)
Caused by: java.lang.StringIndexOutOfBoundsException: String index out of range: 12
at java.lang.String.charAt(String.java:686)
at N64_Controller_mouse.serialEvent(N64_Controller_mouse.java:81)
... 8 more



any ideas?
xenoinc in reply to jhawkman4Apr 12, 2012. 2:42 PM
Step by step procedure to fix your issue:

http://rxtx.qbang.org/wiki/index.php/Download
gamemasterful says: Dec 12, 2011. 11:13 PM
The duke url is dead. Fortunately the code was ported. https://github.com/brownan/Gamecube-N64-Controller is where the stuff is posted now.
diy_bloke in reply to gamemasterfulDec 27, 2011. 8:23 AM
Only the pde and the 'h' file there for Arduino the library shld have an 'h' file and a 'cpp' file ergo: compiling errors on the Arduino IDE
DONPATCH says: Jul 28, 2010. 12:54 PM
I get an error running your n64_controller program saying "cannot find a class or type named robot" can somebody help me.
quasse (author) in reply to DONPATCHJul 28, 2010. 1:07 PM
Try adding "import java.awt.Robot;" "import java.awt.AWTException;" "import java.awt.event.ImputEvent;" if you have processing 1.1
diy_bloke in reply to quasseDec 27, 2011. 8:18 AM
add to what?
1-40 of 88Next »
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!