I’m quite pleased to announce that ever-popular Sony PS3 game controllers are now supported by current (rev.2.0) USB Host Library. Kristian Lauszus from TKJ Electronics developed a library to interface with Dualshock 3, as well as Move Navigation and Motion controllers via a Bluetooth dongle (only CSR-based ones are supported at the moment). This library has been merged into the main code and I will start maintaining it as soon as my Dualshock 3 arrives.
Sony PS3 controllers are advanced versions of ordinary HID joysticks. They can be interfaced via USB or Bluetooth, the buttons can be read as analog or digital and controller contains rumble motor which can be activated remotely to indicate a hit, for example. The controller also contains a gyroscope and accelerometers so it is possible to control a robot by simply waving and/or rotating the controller.
Kristian got his inspiration from Richard Ibbotson’s articles, as well as works by Tomoyuki Tanaka and others (full list can be found in PS3README file). His Wiki page gives implementation details, communication protocol, differences between controllers, as well as plenty of links to other sources of PS3 controller interfacing knowledge.
Kristian developed this library as a part of his Balancing robot project. The project is very well documented – if you are interested in robots, PID or remote control, please take a look. I also enjoyed watching this video presentation, give it a shot to see balancing robot in action.
Oleg.
Related posts:
- Wireless Xbox360 controller support for USB Host 2.0 library
- Bluetooth RFCOMM/SPP service support for USB Host 2.0 Library released!
- A documentation project for USB Host Library 2.0 has begun!
- Balanduino – Balancing Robot Kit on Kickstarter
- USB Host Shield library Version 2.0 released.
- USGlobalsat ND-100S GPS receiver works with USB Host library
- Google Open Accessory Interface for USB Host Shield Library 2.0 released
- Arduino 1.0-compatible USB Host Library released
- Andriod ADK-compatible USB Host Library release.
- PS3 and Wiimote Game Controllers on the Arduino Host Shield: Part 1


This library is great! It’s saved me loads of time trying to get my hexapod robot responding to external input. Unfortunately I have an issue that I can’t figure out. I’ve got a CSR Bluetooth dongle visually identical to the one on the Balancing robot and am connecting it to an Arduino Mega ADK. I can then sync a PS3 Sixaxis controller to it and get the lights changing and read most of the inputs. However, I can’t read any of the analog buttons, the controllers status, or the motion sensor values. The same occurs with a different Belkin branded bluetooth dongle, but both work fine on PC when setup with MotioninJoy, able to read everything.
Anybody got any ideas what I’m doing wrong?
Hi,
I got one bluetooth dongle that has the exact same problem.
If you uncomment PRINTREPORT in PS3BT.cpp, you can see that the data is not changing. I still don’t know what the problem is. I had the same issue when I used it with the FEZ Devices: http://wiki.tinyclr.com/index.php?title=PS3_Controller with the same dongle.
I recommend getting a different dongle. Just buy some different ones at ebay and they will properly work. I think is related to if it’s supports EDR or not, but I’m not sure, as it must support V. 2.0+EDR.
Best Regards
Lauszus
The new ps3 library is graet. Thanks!
The library should work with Arduino UNO?
Did you use any timer or interrupt in the library? Can I still use timer2 to generate an constant 1 msec interrupt?
Thanks!
Yes it works with all the Arduinos supported by the USB Host Shield.
No I havn’t used timer2 in the library. I have only used the standard millis() and delay() functions which use timer0.
Regards
Lauszus
Fascinating articles guys, but what I would really like to see is an Xbox 360 Wireless Controller Library along similar lines to the PS3 and Wii libraries available. Is anybody doing any work on this?
Cheers
I might borrow a Wii Remote someday and port the library to version 2 of the usb host library
For it to work with a wirelessly xbox controller, you will need a special receiver: http://www.amazon.com/Xbox-360-Wireless-Gaming-Receiver-Windows/dp/B000HZFCT2. I don’t know anybody who actually got one, so I don’t think I will create a library in the nearest future. But if I get my hands on a receiver I might take a look at it.
Regards
Lauszus
Hallo,
USB is working correctly with the Shield SPEEDLINK PS3 Controller Type SL-4445-BK.
Once connected via USB cable Controller in August and then reports the number of the program is part of BT Host to Controller. then when you insert the BT dongle everything works great.
But here I have a big problem … Original Sony PS3 Controller Model CECHZC2E b1 purchased today is not recognized by USB Shielt and I can not enter the host address to it .. I thought of is defective and replaced it with another … The same problem.
I tried to apply pressure all the keys on the Serial Monitor controller is there.
Is Genuine Controller Sony need to do something extra?
Please advice, I will not give you the same advice.
I send greetings
RomanF
Maybe Sony changed their controller recently? Check to see if VID/PID of your controller is different from one expected in the code -> https://github.com/felis/USB_Host_Shield_2.0/blob/master/PS3BT.h#L45
How do i pair PS3 controller with BT dongle?
Thanx
See the wiki: https://github.com/felis/USB_Host_Shield_2.0/wiki/PS3-Information#wiki-Setting_the_BT_Address_on_your_PS3_Controller
@Lauszus, I have this code:
void loop() {
Usb.Task();
if(PS3.PS3Connected) {
if(PS3.getButton(TRIANGLE) {
Serial.print(“click”);
delay(1000);
}
}
}
On TRIANGLE press I get diffrent numbers of “click” on Serial monitor. From 6, 8 to 11. Why?
Thank you Lauszus! You are the best
That sound very strange. What happens if you run the example sketch: https://github.com/felis/USB_Host_Shield_2.0/blob/master/examples/Bluetooth/PS3BT/PS3BT.ino. Could you also send me all of the debug strings, so I can see what is going on?
What do you mean by “This can be achieved by plugging the controller in via USB and letting the library set it automatically”
Can you expand on this for me?
There is more information at the readme: https://github.com/felis/USB_Host_Shield_2.0#ps3-library
This is what i get if I press button TRIANGLE once and then CROSS:
PS3 Bluetooth Library Started
Bluetooth Dongle Initialized
No response to HCI Reset
HCI Reset complete
Local Bluetooth Address: 00:15:83:3D:0A:57
Wait For Incoming Connection Request
Incoming Connection Request
Remote Name: PLAYSTATION(R)3 Controller
Connected to Device: 04:76:6E:DA:DD:8C
Scan Disabled
Your dongle may not support reading the analog buttons, sensors and status
Your HCI Version is: 1
But should be at least 3
This means that it doesn’t support Bluetooth Version 2.0+EDR
HID Control Incoming Connection Request
HID Control Configuration Request
Wait For Incoming Connection Request
HID Control Successfully Configured
HID Interrupt Incoming Connection Request
HID Interrupt Configuration Request
HID Interrupt Successfully Configured
Dualshock 3 Controller Enabled
PS3 Controller – Traingle
PS3 Controller – Traingle
PS3 Controller – Traingle
PS3 Controller – Traingle
PS3 Controller – Traingle
PS3 Controller – Cross
PS3 Controller – Cross
PS3 Controller – Cross
PS3 Controller – Cross
PS3 Controller – Cross
PS3 Controller – Cross
PS3 Controller – Cross
PS3 Controller – Cross
PS3 Controller – Cross
PS3 Controller – Cross
PS3 Controller – Cross
PS3 Controller – Cross
PS3 Controller – Cross
PS3 Controller – Cross
PS3 Controller – Cross
PS3 Controller – Cross
PS3 Controller – Cross
I have tried this with 3 original Dualshock3 controllers on Arduino Mega and Leonardo.
What does this means “Your HCI Version is: 1″.
Does this applies to Bluetooth dongle or Dualshock3 controller?
Thankyou.
It applies to the Bluetooth dongle. The best answer I can give you is to try a different dongle, see the wiki for a list of cinfirmed working dongles: https://github.com/felis/USB_Host_Shield_2.0/wiki/PS3-Information#wiki-Hardware
Hi Lauszus,
I’ve got a SparkFun USB Host Shield and a MadCatz PS3 controller. I downloaded the USB Host Library and ran the example sketch PS3USB (after changing the values for VID and PID in PS3USB.h so that they matched my controller’s) and the serial monitor is continuously scrolling and the parameter values don’t change regardless of whether or not I’m pressing any buttons on my controller.
Are there more values that I need to change in the header file? Or is this how the sketch should run? I’m a bit new to this so any help would be appreciated, thanks.
I’ve since gotten a usb cable for my official sony PS3 controller. I changed the VID and PID values once again and the sketch shows
PS3 USB Library Started
Dualshock 3 Controller Connected
Bluetooth Address was set to: 00:00:00:00:00:00
and nothing else; it doesn’t respond to any button presses/holds.
Try to connect an external power supply to the Arduino.
The Sparkfun shield rely on a VIN that it’s greater than 5V since it got an onboard 5V regulator connected to VIN on the Arduino.
hi, i have a problem to pair the dongle with the control( i have 2 dualshocks and 1 sixaxis only detects the sixaxis i dont know why) when i started the serial monitor detect the dongle and shows the address, then i plugged the control and showed dualshock 3 detected and show the same address of the dongle, plug the dongle again and push the ps button but it didn´t pair only flash, what can be the problem? thanks a lot
PS3 Bluetooth Library Started
Bluetooth Dongle Initialized
HCI Reset complete
Write class of device
Local Bluetooth Address: 00:1F:81:00:02:50
Wait For Incoming Connection Request
Write clase of device?
This simply sets the type of the device other devices will see when they do an inquiry. See these lines for more information: https://github.com/felis/USB_Host_Shield_2.0/blob/91d719557762b196e5cd8dccd87ebf9038535142/BTD.cpp#L1024-L1033.
Please post the output from your console when you pair with the controller and I will have a look at it
THANKS FOR ANSWERED, I DONT KNOW VERY MUCH OF THIS,WHAT DO YOU WANT TO LOOK? I DONT UNDERSTAND, COULD YOU EXPLAIN ME WITH MORE DETAILS, PLEASE, I NEED TO CHANGE SOMETHING IN THE SKETCH? THANKS
Please send me the output from the serial monitor after you have done the following: plug in the dongle and then unplug it again. Then plug in your PS3 controller.
Ps3 bluetooth library started
Bluetooth dongle initialized
Hci reset complete
Write class of device
Local bluetooth address:00:1f:81:00:02:50
Wait for incoming connection request
Dualshock 3 controller conected
Bluetooth adress was set to :00:1f:81:00:02:50
Bluetooth dongle initialized
No response to hci reset
Hci reset complete
Write class of device
Local bluetooth adress: 00:1f:81:00:02:50
Wait for incoming conection request
Incoming connection request
Thats all and no pair
The paring is working fine. It is happening when you plug in your PS3 controller and the following line gets printed:
Bluetooth adress was set to :00:1f:81:00:02:50
It’s a problem with your Bluetooth dongle. You will have to try a different one!
Ok i will, the dongle needs something particular? Thanks
See this comment for more information: https://www.circuitsathome.com/mcu/bluetooth-code-for-arduino-usb-host/comment-page-1#comment-21600