Any Playstation Controller Interface Codes?

26 Mar 2012

I would like to interface the playstation with the mbed. Trouble is I can't find any successful code with it. It seems like people have succesfully interface it arduino and PIC but being a total beginner in programming it's just too mind-blowing difficult to me. Appreciate it if anyone could help.

All I like is to succesfully read the up down left right inputs to control a mobile vehicle.

27 Mar 2012

Hello Joey,

You can start here http://mbed.org/users/BartJanssens/programs/PS3_BlueUSB/lq9h2h. This is USB host cappable to work with USB mouses, keyboards, flash disks and hubs from Peter Barrett. Bart Janssens added support for PS3's DUALSHOCK 3 gamepad. You can use both, USB or Bluetooth connection from gamepad to mbed.

To get bluetooth working You will need USB bluetooth dongle. But not every dongle works, You will need those with CSR chip.

And to get mbed to USB host mode, You will have to connect 10 Kohm pull-down resistor between D+ pin and ground and the same for D- pin.

Also look at Peter Barrett's notebook page http://mbed.org/users/peterbarrett1967/notebook/blueusb---bluetooth-and-usb-host-controller-for-mb/ about this USB host.

Hope this will help You.

27 Mar 2012

Hi Llumpu,

Thanks. As I understand from that notebook, if I would to be successful in connecting mbed with the playstation, I would require a USB female connector with 2 10k Resistor? And after that, I would mainly need to import the Ps3USB.cpp [code] and the relevant libraries: ps3.h [code] Utils.h [code] hci.h [code] USBHost.h [code]

Any changes I have to look out for?

Will not be using bluetooth, although I would like to try it one day.

Some minor question, Is the ps2 the same as the ps3 coding wise?

27 Mar 2012

Hello Joey,

Yes, You will need USB female socket. Me for example uses one half of USB extension cable (second half I use for projects where mbed acts as USB device). Each of those 10K resistors You connect between D+ (or D-) and GND pin. Then connect white and green wires to D- and D+ pins. Red wire connect to Vout pin to feed connected with power and black wire connect to GND.

For start You can import whole example program and compile. If You use terminal on Your PC, You will be able to see values sent by DualShock 3 gamepad. Those values show pressure data for buttons and values of axes for sticks and values for accelerometers and gyro. As I remember there are not printed out to terminal data for Select, Start and PS buttons(they are not pressure sensitive). But it only means that You can't see them on terminal in program as is but mbed receives them and after some changes You can see them on terminal and also use them in Your project. All data from controller are stored in structure.

PS2 controller isn't USB but uses another "protocol". Code to use PS2 gamepad and read values is here http://mbed.org/users/simon/programs/PlayStationController/16mhs4 from Simon and nice notebook page herehttp://mbed.org/users/vcazan/notebook/second-life-rock-band/ by Vlad Cazan.

For both is same that You receive actual state of all buttons, axes, (gyros) in one report x times per second.

Typicall gamepads sends each axe as one byte and 8 buttons in one byte. Dpad uses nibble - half byte. This typicall gamepad report is 6 bytes in length. 4 bytes are for 4 axes and two bytes store value of 12 buttons(12 bits of 16) and Dpad.

I hope this help You. If You wish ask more.

31 Mar 2012

Thanks.

I haven't tried it yet, will let you know if it's successful.

I'm not great at programming, but if I read off the values return for any of the buttons pressed, How do I assigned it to any variables I choose.

For example, if I read the byte value for up button from the playstation, how to pass that value to to a declared variable "up"?

15 Apr 2012

hi llumpu,

I tried it out but the terminal is unable to receive any byte data values out from the controller. The terminal screen prints out error instead asking it to be reconnected.

Since this uses a USB Hub maybe it requires a USB Hub to be connected first?