PlayStation 2 Controller Arduino Library v1.0

Posted in Arduino Libraries by Bill
5 Jun 2010
PlayStation 2 Controller Arduino Library v1.0

Want to interface a PlayStation 2 Controller with an Arduino Microcontroller? You have come to the right place. Below you will find a link to download an easy to use library that takes care of all the interfacing for you, so you can start using the controller right away for your project. Don’t forget to link your cool projects in the comments, I’d love to see what you do with the library.

First, a brief history:

A while ago, I spent countless days trying to interface an Arduino and a Play Station 2 controller. I wanted to build a controller for my SAGAR robot, and figured PS2 + Arduino would be perfect. However, no matter what I did, no existing library would work for me. I shelfed the project for a while, but recently found this forum post with some code by a member named Shutter. I tried out the code, and to my surprise, IT WORKED!!! Well, mostly anyway. It didn’t really have analog stick support, nor was it formatted into an easy to use library. Well, through need I spent some time adding analog stick support, and formatted it into a library. It works fine on my Arduino Pro mini.

The first fully working version (v1.0) is now available. 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.

Source Code available on GitHub project page.


Download PS2X


Old Versions:


PS2X lib v1.41

Arduino PS2 Controller Library V1.5

Wiring the Controller

The seemingly most notorious part prone to errors is wiring the controller to the Arduino. Lynxmotion sells a nice breakout connector available HERE.


The Lynxmotion adapter may not follow the color wiring diagram below. Instead, it might follow this diagram. (Lynxmotion only). Be careful and use a volt meter to confirm pin positions.

Or, to wire the controller not using the Lynxmotion adapter, follow the pinout in the following picture from the amazing CuriousInventor PS2 Interface Guide:

Image Source: CuriousInventor

A note from CuriousInventor: “Red – Power: Many sites label this as 5V, and while this may be true for Play Station 1 controllers, we found several wireless brands that would only work at 3.3V. Every controller tested worked at 3.3V, and the actual voltage measured on a live Playstation talking to a controller was 3.4V. McCubbin says that any official Sony controller should work from 3-5V.”

Here’s a video demonstrating the library.

Guitar Hero Controller Example

The following is a video and source for example of how to use the library with a Guitar Hero Controller.

Source: (tested with v1.5, should work with v1.6 as well)

Guitar Hero Example Arduino Code

Guitar Hero Example Processing Code (thanks Patrick)

Another Demo

Author unknown

Project Showcase

Hey guys, feel free to drop a link off in the comments to your project that uses my library. I’ll post it here.

  1. Guitar Hero Axe Controlled Flamethrowers by Chris Marion
  2. Scanalogic Review by CuriousInventor
  3. SAGAR by Me
  4. Remote Controlled Robot (Video) by ‘teachengineering
  5. ‘America Dream’  Electric Hammock by Stephen Shaffer
  6. Life size R2D2 robot by Dan
  7. Simon Says via DDR mat by Dalpix


Follow my troubleshooting guide first and then visit the Support Forum if you still can’t get it working. Don’t ask for help in the comments below.
Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.


Trackbacks / Pingbacks

  1. I, Robot | gr33nonline
  2. Interfacing PS2 Wireless Controller With Arduino
  3. A Simple Remote-Controlled Arduino Tank | Paul Bleisch
  1. 587 Comments.

    • Leonardo DouradoNo Gravatar says:

      Hi dear!
      I was very happy when i had find your ‘step by step’ to use the PS2 joystick. But when i had tried by the first time, all went wrong. The solution: I change the console. The control i was using have serious problem, but with a other control all it’s okai!! thanks!!! ( I’m sorry due to my english level – i don’t know speak and writte like a true american)

    • BastienNo Gravatar says:


      I have download the librarie but when i verified the exemple i’ve this error message:

      PS2X_Example.pde:1:34: fatal error: PS2X_lib.h: No such file or directory

      What’s the problem???


    • BastienNo Gravatar says:


      I have download the librarie but when i verified the exemple i’ve this error message:

      PS2X_Example.pde:1:34: fatal error: PS2X_lib.h: No such file or directory

      What’s the problem??


    • […] anything with ps2 controller and Arduino (wirelessly) can use an old remote receiver. Also, this playstation-2-controller-arduino-library-v1 article is very […]

    • Danilo CostaNo Gravatar says:

      Fiz o download da biblioteca para utilizar o controle do playstation 2 mas, estou com um problema que o arduino não esta reconhecendo os arquivos depois de descompactados e assim sendo ele até mostra o exemplo na IDE só que não reconhece o include da biblioteca.
      Estou usando a versão 1.6.4 do arduino software instalado em SO windows 7.
      Poderia ajudar-me por favor.
      A mensagem que aparece quando faço a compilação do exemplo é a seguinte; ( “fatal error: PS2X_lib.h: no such file or directory”) .

    • Himanshu Ranjan SethNo Gravatar says:


      My PS2 wireless controller is working very well with Arduino UNO but I am fetching a problem that I am not able to control THUMBSTICK.

      Please provide me an example for THUMBSTICK control.

      Thank you

    • […] have used the PS2 library for Arduino from which can be downloaded from the github link provided at the bottom of this page. […]

    • JackNo Gravatar says:

      Can anyone confirm that it works with a 8MHz 3.3v Arduino, like the Mini ?
      Is there any drawbacks ?
      Does it feel less responsive ?

      Thanks !

    • neilNo Gravatar says:

      i did all the connections proper and also went through the troubleshooting options but still i am stuck with error 3…All my digital buttons are working but the joystick is not responding…. Can anyone help me with this problem???

    • Eric BairdNo Gravatar says:

      Awesome work! My son and I using this for a submersible ROV project. Thanks

      We are having troubles getting our 2560 to see the controller. Triple checked wiring, all solid. We are getting the ANALOG button to light up, but the serial monitor continues to output:

      “No controller found, check wiring, see readme.txt to enable debug. visit for troubleshooting tips
      Unknown Controller type found”

      We even tried a 5v pullup resister on the orange and yellow wires.

      We tried an original PS2 wired controller, and a cheap clone

      Please help! what are we doing wrong?

      • neilNo Gravatar says:

        i was having the same problem…just give 5volts vcc instead of 3.3v…. after that the unknown controller problem was solved for me…

      • AshleyNo Gravatar says:

        There’s a value in the ‘PS2X_lib.h’ file that governs the speed of the bus to the controller. It’s called ‘CTRL_CLK’ and you can find it by looking for this line:

        #define CTRL_CLK 4

        The PlayStation 2 talks to its controllers at 500kHz, or a value of ‘2’ in my library. Arduino tends to have issues setting a value that low, so by default I have it set at 4. You can try using 2 instead, and I’d also try using some higher number for a slower bus speed. Go from 2-20 and even 200 to see if you can get the controller talking. Remember to save the .h file every time you edit it, and re-compile the sketch.

    • neilNo Gravatar says:

      Can someone please help me with error 3 in serial monitor???
      Due to that my joysticks are not working….

    • […] for the PS2 controller, soldered on some jumper pigtails and connected it to the Arduino. Using PS2X from Bill Porter, I got basic remote control working pretty […]

    • neilNo Gravatar says:

      I am trying to get a serial communication between arduino uno and arduino due.
      Ps2 is connected to arduino uno and using software serial i am assigning 2 pins of uno as Rx and Tx that communicates at baud 9600.. That pins are connected to one of the Rx and Tx of Due which takes values at 9600.
      But i am not getting the Buttons pressed on the controller on Serial Monitor of Due.. Can someone suggest something?

    • AshleyNo Gravatar says:

      Hey Bill,

      Was just wondering if there was a way to add something to the library or sketch code which would scan through the different values to find the controller as stated in your trouble shooting thread (You can try using 2 instead, and I’d also try using some higher number for a slower bus speed. Go from 2-20 and even 200 to see if you can get the controller talking)

      I have no programming skill at all (so excuse me if it’s a dumb question), i am currently playing around trying to teach myself on arduino at a homebuilt rov forum.

      This would be handy if possible

      Kind regards

Leave a Reply