Home > Arduino, Bluetooth, TKJ Electronics, USB > PS4 controller now supported by the USB Host library

PS4 controller now supported by the USB Host library

I am very pleased to announce that I have now added support for the PS4 controller via Bluetooth. This will allow you to read all the buttons and joysticks with the same API as all the other libraries I have written for the USB Host library.

PS4 controller

To get started you should look at the provided example. It shows how to read the different buttons and joysticks. I still haven’t figured out how to control the light, rumble and read the accelerometer, gyroscope and touchpad, but hopefully I will figure that out soon.

The pairing process for the PS4 controller is a little different than the PS3 controller, as it works like a regular Bluetooth joystick, as you simply make the PS4 controller discoverable by holding down the PS and Share button at the same time. The light will then start to blink rapidly.

After that you should be able to pair with the controller, by creating the PS4BT instance like so:

PS4BT PS4(&Btd, PAIR);

You should also check out the readme which will always have the newest information available.

The PS4 Bluetooth library actually uses the BTHID library to handle all the Bluetooth communication. This is much more modular and easier to maintain. I will work on making all the Bluetooth classes like that, so it will reduce the footprint of the libraries, but also make it much easier to maintain, as all the L2CAP communication would be handled in only one class.

I still haven’t written a library to use it via USB, but I will do that in the coming weeks, when I have time.

This is all for now. Please leave a comment below if you got any questions and I will answer as quickly as possible.

Update 18. January 2014
A USB version of the library is now also available. It allows you to read the gyroscope, accelerometer and touchpad as well.

Update 22. January 2014
I now also figured out how to read the IMU and touchpad data via Bluetooth. The problem is that the controller does not send out this information via Bluetooth by default.
To enable the full output the code sends out a get feature report. For more information see this excellent Wiki: http://eleccelerator.com/wiki/index.php?title=DualShock_4 by Frank Zhao.

Update 16. February 2014
It is now also possible to control the rumble and light as well. The code was inspired by this Linux driver: https://github.com/chrippa/ds4drv.

Categories: Arduino, Bluetooth, TKJ Electronics, USB Tags:
  1. Sammy
    January 14th, 2014 at 02:50 | #1

    Great! Was exactly looking for this. Thanks for sharing.

  2. January 14th, 2014 at 22:48 | #2

    You are welcome! It is always nice to see that people find it useful :)

  3. Raggy
    January 19th, 2014 at 20:18 | #3

    Amazing! I don’t have arduino, but do use PICAXE. Got any tips for connections? i.e. what do I need to serial out to connect? Will serial out and in work?
    Thanks a bunch

  4. January 19th, 2014 at 20:30 | #4

    You will need the USB Host Shield: http://shop.tkjelectronics.dk/product_info.php?products_id=43 for it to work, but for now PICAXE is not supported by the library.

    Anyway they communicate via SPI. The relevant code is in the following file: https://github.com/felis/USB_Host_Shield_2.0/blob/master/usbhost.h.

  5. Matt
    January 20th, 2014 at 09:40 | #5

    I cant get a working dongle?!? Ive tried 3 of the cheap half mooned ebay ones and no luck. Any help?

  6. January 20th, 2014 at 12:53 | #6

    What errors are you getting when you plug them in?
    There is a list of working dongles here: https://github.com/felis/USB_Host_Shield_2.0/wiki/Bluetooth-dongles.

  7. Jake
    February 1st, 2014 at 04:31 | #7

    Hey ive been trying to use this library with a USB host sheild I got online but when I run the PS3BT script my serial monitor just returns random symbols. Has any one else experienced this issue and found a way to resolve it?

  8. February 2nd, 2014 at 10:21 | #8

    You need to set the baudrate in the serial monitor to 115200. See the dropdown menu in the bottom right.

  9. Azim
    February 23rd, 2014 at 14:41 | #9


    I have purchased the USB Shield and cant wait to get on with it, I really appreciate your efforts and this great work.

    I am currently planning to build a robot and was doing some research on interfacing XBOX 360 controller via BT and came across your great site, I will be going through the information provided should I require any assistance will be in touch.



  10. February 23rd, 2014 at 16:31 | #10

    Glad to hear you like my work :) Note that the Xbox 360 wireless controller needs a special wireless receiver and is NOT using Bluetooth.
    Please see: http://blog.tkjelectronics.dk/2012/12/xbox-360-receiver-added-to-the-usb-host-library/.

  11. Joe M
    April 13th, 2014 at 21:39 | #11

    Hi guys!

    (First of all, sorry for my english level, I’m not an native english speaker…)

    So, I’m a newbie for Arduino stuff, but I’d like to start a project whit it. I want to control a very simple illumination system, you know turn on/off some lights maybe a dimmer.

    I’ve read this could be done by an Android device, but if it’s possible, i’d like to control it whit a PS controller, I dont care if PS3 or PS4.

    Does anybody think it could be possible to do whitout the USB host shield? because if I do that I’ll do it whit a BT shield and I’ll use Arduino UNO.

    Hope anyone could help me!

    Thanks for reading!

  12. April 13th, 2014 at 23:17 | #12

    @Joe M
    No you can’t use a normal Bluetooth shield, as it doesn’t support Bluetooth HID. Also the PS3 controller behaves a bit different, as you need to send a special command to it before it starts sending out data.
    If you want to know more about it, then see the PS3 wiki I wrote: https://github.com/felis/USB_Host_Shield_2.0/wiki/PS3-Information.

  13. Joe M
    May 9th, 2014 at 06:03 | #13


    Hi Lauszus! Thank you for reply!

    I’ve already bought the usb shield and BT dongle, so I could run the example!

    Then I got a bunch of doubts XD. Let me explain you and maybe (I hope) you can help me.

    The thing is, I want to use a couple of outputs to control a little DC motor, but if you could tell me how to turn on a led it’ll be more than useful!

    So, it’s posible to do? And if yes…. how can i do it?

    Thank you again, take care :)

  14. May 9th, 2014 at 11:51 | #14

    @Joe M
    It’s really simple :)

    Here is some example code:

    if (PS4.getButtonPress(CROSS))
       digitalWrite(led, HIGH);
       digitalWrite(led, LOW);

    Note that if you are using an Arduino Uno, then you can not use the build in LED, as pin 13 is used by the shield for SPI communication.

  15. Joe M
    May 21st, 2014 at 23:40 | #15

    Man, you’re so kind! I found that code very helpful. But now I got a new problem ( sorry again I’m new on this :( ). When I pair de DS4 sometimes I lost the connection after 3 mins. I suppose that it ain’t normal. Haha… I tried using a new dongle (trendnet TBW 107 UB) but the arduino can’t recognise it.

    Do you think it’s a matter of the first dongle, or code…. Maybe bad luck? Hahaha

    Thank you very much for your replies and help.

    Ps. Sorry for write my feedback almost 10 days after your reply.

  16. May 22nd, 2014 at 00:03 | #16

    @Joe M
    Make sure that the dongle is getting a stable 5V also make sure that there is actually battery left on the PS4 controller? You can use the following function to read the battery level: https://github.com/felis/USB_Host_Shield_2.0/blob/2c5f5e8c0964c1639265486b6fac17739a55f1d2/PS4Parser.h#L259-L265.

    Also what is the output when it disconnects?

  17. Joe M
    June 2nd, 2014 at 02:33 | #17


    Man! Thank you very much! you was very helpful!! Seriously, you helped me a lot whit my final project!
    The trouble was the input to arduino, (wasn’t 5V stable as you said).
    Then I was able to control a RC car using DS4, USB Shield, the BT dongle and Arduino UNO!

    Again, thank you very much!

    Take care man, Cheers from Mexico!

  18. Joe M
    June 2nd, 2014 at 02:36 | #18

    @Joe M

    HAhaha I wrote “you was” I ment “You were”

    Just a little mistake XD Sorry!.

  19. June 2nd, 2014 at 11:08 | #19

    @Joe M
    Glad to hear that everything worked out for you :)

  20. Tony W
    July 26th, 2014 at 03:09 | #20


    Awesome work first of all! I’ve used the PS4USB library without a hitch, however with the PS4BT example, it seems that I can only pair the PS4 with the dongle once…. in a while, and after that they can no longer pair (LED keeps flashing rapidly then eventually the controller shuts off). I know that in your instructions it says I only need to pair it once, and then I can just create an instance like this: PS4BT PS4(&Btd); and then simply press the PS button. But when I do that, the PS4 will just begin looking for the console (slow flashing LED) and not connect with the BT dongle…and suggestions? Thanks!

  21. July 28th, 2014 at 09:24 | #21

    @Tony W
    Please enable serial debugging: https://github.com/felis/USB_Host_Shield_2.0#enable-debugging and send me the output ;)

  1. No trackbacks yet.