PlayStation 2 Controller Arduino Library v1.0

Bill | June 5, 2010 in Projects, Source Code, Tutorials, Videos | Comments (29)

The first fully working version (v1.0) is now available. I split this into a new blog post, as many things have changed.

The big change is you can now define what pins of the Arduino are used, no longer are you tied to pins 10-13.

Also, vibration (Rumble) and analog button pressure readings (how hard is a button being pressed) are now working.

The library has changed names. PSX -> PS2X to avoid confusion with other sets of code. Sorry for those that need to change a bunch of their programs.

I had to rewrite a lot of code that powers the library, there is not much left of the original code written by Shutter of Arduino forums. There were many bug fixes, now the controller should automatically be in analog mode, and the mode button should be locked. There’s also a catch to make sure not to much time has past since the last controller reading. If there was, it will configure the controller again, in case it timed out.

Download here:

PS2X lib v1.41

Old Versions:

PS2X_lib_v1.0

PS2X_lib v1.3

PS2X lib v1.4

For those who missed the excitement the first time, here’s a wiring diagram(from the amazing CuriousInventor PS2 Interface Guide) and demonstration video:

Image Source: CuriousInventor

Here’s a video demonstrating the library.


29 Responses to “PlayStation 2 Controller Arduino Library v1.0”

RSS feed for comments on this post. TrackBack URL

  1. Comment by Bob — July 19, 2010 at 9:27 pm  

    Hi Bill,
    I did change CLK line from pin 13 to 9 and it worked great. I had noticed the LED tied to PIN 13 was constantly going HIGH/LOW so this resolved that issue. It is still not constantly detecting the controller so I can only assume I may need to try a different resistor. On another note, I am trying to program a VB.NET app to read the data from the arduino through the virtual com. I am using Firmata.dll as the intermediary to create the connection but I’m not sure how to read the data. I was wondering if you have a reference or familiarity with this? Thanks

  2. Comment by KylerAugust 1, 2010 at 4:33 pm  

    Here’s something interesting I noticed – the controller won’t be detected if analog mode is already on. Caused a lot of head-scratching!

  3. Comment by Bill — August 1, 2010 at 7:09 pm  

    Hmm, I thought I considered all states in the initial check, but I’ll have to go back and see if I implemented it right. If there is a bug, I’ll fix it in the next release. Thanks for the report!

  4. Comment by grehe — August 5, 2010 at 10:34 pm  

    Nice. I tested the code (v1.3) and it returns an error level2 “controller found but can’t communicate”. I then removed the error check and it works nicely. So this lib could work on psx as well.

  5. Comment by Bill — August 5, 2010 at 10:44 pm  

    Grehe, i’m having a hard time understanding you. Are you telling me that you were trying my lib with a PS1 controller, but the error check is wrong? OR did this happen with a PS2 controller?

  6. Comment by Eric — August 9, 2010 at 10:09 am  

    Bill,
    I changed a few minor things (button definitions, ‘analog’ mode check) in your code and I’d like to recontribute my changes. Is there an e-mail address where I can send my zip file?

  7. Comment by Bill — August 9, 2010 at 10:13 am  

    Sure. bill@[this website's address] will do. (I avoid putting the whole address to keep spam bots from sniffing it)

    I have already fixed the analog mode check, but i’ll take a look at what you have.

  8. Comment by Bill — August 14, 2010 at 4:59 pm  

    Updated to 1.4. Fixed controller not detected if in analog or pressures mode now.

    Thanks to Eric for contributions.

  9. Comment by Bill — August 29, 2010 at 1:47 pm  

    Updated to 1.41. Some simple bug fixes and added keywords.txt file.

Leave a Reply