NESpad/SNESpad: Nintendo Joystick Libraries for Arduino
I wrote this library, called NESpad, for anyone who wants to interface an NES game pad with the Arduino microcontroller. I also made an SNES library (SNESpad), but I haven’t tested it with an actual SNES joystick.
I’ve moved everything over to Google Code! Go to http://code.google.com/p/nespad/ to see all the information that used to be here.
If this post is interesting to you, subscribe to this site.
Posted: September 21st, 2007 under antimusic, electronica.
Comments: 16
Comments
Pingback from joystick, ae!!!salvou « ; (re)rb~
Time: October 26, 2007, 2:59 pm
[...] deu outra… o joystick foi pra solda, comecei a pesquisar, achei um blog de um cara que fez uma lib no arduino pra controlar esse tipo de joystick, dei uma estudada na lib [...]
Comment from Ricardo Brazileiro
Time: October 26, 2007, 5:53 pm
Hello..
Congratulations for the arduino library.
I using and testing the lib.
Thanks.
Comment from Dan
Time: November 12, 2007, 9:32 pm
Thanks for the great library. Works great!
Comment from LC
Time: December 16, 2007, 1:20 pm
when I use this I get a very long string of 1s with the data at the end of it. So:
111111111111111111110011
if start and select is pressed down
how do I fix this
I am using Arduino-10
Comment from rob duarte
Time: December 16, 2007, 1:41 pm
LC, did the example sketches work for you? “buttons()” should return one byte (a sequence of eight 1′s or 0′s), representing the status of all of the buttons. If you run the NESpad_serial.pde example sketch, you *should* be seeing those 1′s and 0′s. Look at the NESpad_LED.pde example for an example that lets you use the library to check on the joystick state without caring about 1′s and 0′s. Email me if the examples sketches don’t clear things up.
Thanks,
rob
Comment from Undervand
Time: January 16, 2008, 5:04 am
I tried the SNESpad library with a Super Famicon Joypad and it worked beautifully :D I had to change the “byte state=0″ into “int state=0″ in the code though for all the buttons to react. That’s because the X, A, R and L buttons use bits 8,9,10 and 11 and they are truncated when “state” is only one byte. I now use my SNESpad as a MIDI controller in Ableton Live, providing me with a physical interface to adjust playback speed, allowing me to beatmix my own songs into an otherwise analog DJ set :D. Will post more info when I get around to take photos and the like. Big thanks to Rahji for making this possible. It is probably one of the easiest hacks in the world :)
Comment from Rob Hart
Time: September 21, 2008, 2:44 am
Hello Rahji,
i have been absolutely loving this library!
only problem it’s doesnt seem to work with the new arduino 0012, throws up a heap of errors (see below)
i wonder if anything could be done about this to resolve it??
Many Thanks Rob!
In file included from C:\arduino-0012\hardware\cores\arduino/WProgram.h:4,
c:/arduino-0012/hardware/tools/avr/lib/gcc/../../avr/include/stdlib.h:80: error: expected unqualified-id before ‘int’
c:/arduino-0012/hardware/tools/avr/lib/gcc/../../avr/include/stdlib.h:80: error: expected `)’ before ‘int’
c:/arduino-0012/hardware/tools/avr/lib/gcc/../../avr/include/stdlib.h:80: error: expected `)’ before ‘int’
c:/arduino-0012/hardware/tools/avr/lib/gcc/../../avr/include/stdlib.h:111: error: expected unqualified-id before ‘int’
c:/arduino-0012/hardware/tools/avr/lib/gcc/../../avr/include/stdlib.h:111: error: expected `)’ before ‘int’
c:/arduino-0012/hardware/tools/avr/lib/gcc/../../avr/include/stdlib.h:111: error: expected `)’ before ‘int’
c:/arduino-0012/hardware/tools/avr/lib/gcc/../../avr/include/stdlib.h:144: error: expected identifier before ‘(‘ token
c:/arduino-0012/hardware/tools/avr/lib/gcc/../../avr/include/stdlib.h:144: error: expected `)’ before ‘(‘ token
c:/arduino-0012/hardware/tools/avr/lib/gcc/../../avr/include/stdlib.h:144: error: expected ‘,’ or ‘…’ before ‘(‘ token
c:/arduino-0012/hardware/tools/avr/lib/gcc/../../avr/include/stdlib.h:144: error: expected initializer before ‘)’ token
c:/arduino-0012/hardware/tools/avr/lib/gcc/../../avr/include/stdlib.h:176: error: ‘__compar_fn_t’ has not been declared
In file included from C:\arduino-0012\hardware\cores\arduino/WProgram.h:6,
Comment from rob duarte
Time: September 24, 2008, 8:52 pm
Thanks for the bug report, Rob. I’ve fixed the problem and I’m uploading version 1.1 of both NESpad and SNESpad right now.
Comment from John barin
Time: December 10, 2008, 12:55 pm
Hello and thanks for this release!!
I have been uploading the sketch in arduino and it works.
Then I have tryed linking arduino to pduino (patch made for arduino to communicate with pure data)
Would someone have an alternative to make the nes pas communicate with any other software and if yes how??
For pure data has it got to do with the Firmata to upload in the arduino board.
Greetings from France.
Comment from Josh Clark
Time: December 30, 2008, 2:55 am
I am having the same problem as LC. When I run the NESpad_serial file, I get long lines of numbers instead of only 8. Through a little testing, I found out that every time you press a button, it always reports that the ‘A’ button is pressed down, even if it is not. This only happens when I press a button, so the ‘A’ button is not stuck or anything. Any help or suggestions? I kinda need a quick fix for this problem.
Thanks
Comment from rob duarte
Time: December 30, 2008, 12:02 pm
Hey Josh, LC didn’t actually have a problem. That’s what the output of that particular example sketch is supposed to look like. (I’m going to be revisiting this library when I get back to my studio in a week and I’ll include more intuitive example sketches I guess). Did you try the other example? As far as the behavior you described, I’m sure there could be a bug in the library but that would be a pretty major problem and I’d think it would have been noticed by now. (Since the library’s ONLY function is to detect a button press, basically!) :) Are you sure everything is wired correctly? If you have a week to wait for me to get back to California, I can probably be of more help.
Pingback from Arduino Tutorials « Think carefully!
Time: March 10, 2009, 2:48 pm
[...] I didnt have any sensors available the next tutorial I tried involved a Nintendo Controller(I just happened to have an old controller lying around) Although I sadly never got it working a [...]
Comment from Marti
Time: March 10, 2009, 3:40 pm
Hi !
I have find this Arduino library very usefull and easy to use.
Thx
But I would like to connect a second nespad (for two players) on the same arduino board.
Actually I have try to use the same Strobe et Clock output and two data input but it’s not working…
Can you help me?
Thx
Comment from rob duarte
Time: March 10, 2009, 5:39 pm
it sounds like you probably have it wired correctly, but the library was only written for one game pad. i am still hoping to make some changes to this library to make it more useful – i can easily add the ability to connect multiple game pads at the same time. in the meantime, you should be able to tweak it a bit to work with 2 pads. i am completely swamped at the moment but i can tell you that i would probably take the DATA constant (the pin number for data line) in NESpad.cpp and make it a parameter for the constructor instead. That way instead of doing something like “NESpad nintendo=NESpad()” in your code, you could call it like “NESpad(7)” to make an NESpad object that corresponds a game pad with its data line connected to the Arduino’s digital i/o pin 7. sorry if that’s confusing – i’m hoping to integrate everyone’s comments into this library soon .. maybe during spring break.
Comment from Rob Hart
Time: April 15, 2009, 12:23 am
Hey Guys,
been using this library in Arduino 0013 for quite a while without any problems but since i’ve upgraded to 0015, it compiles and uploads ok but doesnt seem to be working, can anyone confirm this for me?
Cheers Rob.
Comment from JR
Time: April 20, 2009, 8:07 am
Hey guys,
I use 0015 with a Arduino Mega and some of the buttons of my snes controller don’t work anymore when using the SNESpad_LED sketch?
X and A button and the SNES_L and SNES_R button don’t work. The rest is still working :)
Using the SNESpad_serial all buttons seems to be responding.
Best regards.
Write a comment