Go Down

Topic: Playstation Controller (Read 35271 times) previous topic - next topic


Mar 14, 2010, 07:21 am Last Edit: Mar 14, 2010, 07:27 am by mannyr7 Reason: 1
Another update.

I connected a wired Sony Dualshock 2. Same continuous stream of button presses printed to serial terminal. Even when power and ground disconnected!  :o

Oh and the button presses are not random, they are in order of 'if.. then' tests, 'SELECT' through 'X'.


you ur terminal thing is at a different baud then the board, in the setup function, there is a Serial.begin(some number); the monitor has to be the same number thing.......


No thats not it. Serial begin is 57600 and so is terminal. Anything else would just read gibberish. And I am not pushing any buttons, so why the output?


Mar 16, 2010, 07:42 pm Last Edit: Mar 16, 2010, 08:29 pm by Entex Reason: 1
Hey. I just tryed this out and was amazed. :P i just wonder, is there any outputs. So i can use the PS control for something. In the best case like a 16 bit serial so i can convert that to parallell (with a multiplexer) and use it for whatever i want?

Sorry for bad English. Im from Sweden you know ;)

Anyway. Thanks for everything. Hope you can help me out :D


ow. Nice i got this to work :P

void loop () {
    int hejhej = 7;

i will continue to try this out more.. hopefully i will learn my way and get my 16 bit serial multiplex cutcutpewpew :D


I too seem to get a similar result to mannyr7 using a PS1 controller.

I get a stream of button presses without actually pressing anything.

could someone tell me if this to be expected or am i doing something wrong. I've been trying to get this to work for ages



In my situation, I'm thinking its the decode byte. But I have no idea what to replace it with. And PS1 controllers are half the clock of the PS2, if I remember correctly.


Can someone post some pictures as how they hooked theirs up to their arduino?


Yes, can someone post pictures of it being wired up; hopefully to the mega.


I have tried so much code (from many sources) over at least a month and nothing works.  I have to edit the <include> code to even get it to compile, even then it still does not work.  

Please, those of you that have had success with hooking up a Playstation 2 gamepad to their Arduino (I have a non-mega), please post your electronics hookups and full code as it would really help the rest of us out that are clearly missing something.  



May 28, 2010, 10:30 pm Last Edit: May 28, 2010, 10:31 pm by mrbang Reason: 1
i've european ps2 and my controller's  hw board is different!
in many different sites this controller has different colors..
this is mine with color cables


and this is other websites with different colors


i have arduino2009

i want to be able to use analog sticks to pilot servos and other things..
and i'm confused 'cause this color's difference




Shutter I could kiss you. Weeks trying to get other PS2 controller libraries working and your last code post works like a charm on my Arduino Pro mini.

But it looks like there it doesn't support the analog sticks yet? I need those as I am build a controller for my ground vehicle.

I really would like those analog sticks to work, and I'm willing to make a donation to you for the work finishing you library. If you beat me(I'm gonna try in the mean time) at adding analog stick values to your code, i'll give you a $20 donation.  If you don't believe me, PM me a PayPal email and I'll send you $10 for getting me this far already, and another $10 when you add the stick values.


Jun 01, 2010, 01:00 am Last Edit: Jun 01, 2010, 01:02 am by madsci1016 Reason: 1
Well, I seemed to have devised my own addition that reads stick values.

Code: [Select]

In header:

//These are stick values
#define PSS_RX 5
#define PSS_RY 6
#define PSS_LX 7
#define PSS_LY 8

Then as a function.

byte PSStick(unsigned int stick) {
 return PS2data[stick];

So PSStick(PSS_LY) returns the value of the left sticks Y axis.

Offer for donation still stands if you put a little work into making this a library, commenting the code on how it works, and/or come up with a better method of reading the sticks then I.


Well, through need I went ahead and did my best to make Shutter's code into a library with analog stick support. (Shutter, hope you don't mind, I still want to donate to you if you PM me a paypal address)

The library, example sketch, and details are all available on my website at:


Please post comments / bugs there if you are using my lib version of Shutter's code.


I've started going full speed on making my version of the library more powerful. Here's a taste:

psx.Button(this_button) is TRUE if this_button is currently pressed
psx.NewButtonState() will return TRUE if any button changed state
psx.NewButtonState(this_button) will return TRUE if this_button changed state
psx.ButtonPressed(this_button) will return TRUE if this_button was just pressed
psx.ButtonReleased(this_button) will return TRUE if this_button was just released

I think that this should cover all possible uses for a button.

I'm not going to keep updates on this forum, so be sure to check my site for updates with bug fixes and more features. Up next on my list is to enable rumble and read the button pressures.

Go Up