OLD PlayStation 2 Controller Arduino Library
Outdated. Go to new library HERE
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.
Here are my library files, and an example Arduino sketch that uses it. Enjoy, and comment here with any bugs you find.
To install the lib, unzip the Source Files zip into your Arduino/hardware/libraries directory.
Go to new library page HERE to download.
Note: The library is hard coded to use pins 10-13 for interfacing the controller. When I get time, I’ll add code that lets you change the pins when initialized. For now, the pin-out is as follows:
PIN Name Color
10 Attention Yellow
11 Command Orange
12 Data Brown
13 Clock Blue
Image Source: CuriousInventor
Hack-a-day Visitors: I’m honored to be featured on Hack-a-day, and hope this helps out some fellow builders. I also want to re-iterate that I started out with existing code by Shutter of Arduino forums and added analog support, as well as turned the code into a working library. I can’t take all the credit.
Here’s a video demonstrating the library.
This code is demonstrated in the video. The program works by setting up the library, initializing the controller, and continuously reading the controller and sending the data to the robot.


Updated Library posted in another blog post.
Go here:
http://www.billporter.info/?p=240