Creating a DualShock 4 Controlled Arduino




With just a few extra pieces of hardware, upgrade your Arduino to receive input from a Sony DualShock 4 controller via a Bluetooth connection.

Teacher Notes

Teachers! Did you use this instructable in your classroom?
Add a Teacher Note to share how you incorporated it into your lesson.

Step 1: Gathering the Hardware

Here is all the hardware you'll need to control your Arduino with a DualShock 4 controller:

1. Arduino Uno - Microcontroller board that allows a user to run their own custom firmware.

2. USB 2.0 Host Shield - This is a must. Found here, the USB Host Shield fits right on top of the Ardiono Uno and provides support for many USB devices.

3. USB Bluetooth dongle - There is a list of Bluetooth dongles that are compatible with the USB Host Shield, many of them very small and cheap. I got mine on Amazon here.

4. DualShock 4 controller - This controller works via a Bluetooth connection with a PlayStation 4 video game console by Sony. With the USB Host Shield libraries, we have full access to the controller's many buttons, joysticks, triggers, gyroscopes, accelerometers, and LED. The controller charges with a micro USB cable, so it is also possible to use the controller in a wired fashion with the board, but we're interested in the wireless capability.

5. Computer with USB port - The Arduino requires another computer to write programs for it and a serial connection to write to the Arduino board. Connect the Arduino to a computer via the USB B port on the chip. This USB connection provides both power and serial communication to the board. For any software-related steps, I will be assuming that you're using a Windows PC, for simplicity. All of the following is possible with very little extra work in both Mac and Linux. If you run into any compatibility issues use Google to find an OS-specific solution, I promise they all exist.

Step 2: Install Arduino Software

If you haven't already, download and install the Arduino IDE 1.0.5 here. This software allows you to write programs for your Arduino and uploads them to the board for you. This software will also be necessary to link the USB Host 2.0 libraries, which provide the code to communicate with the DualShock 4 controller. Remember to download the file for your specific operating system and install the Arduino IDE somewhere you'll be able to find.

The Arduino IDE is very simple, a few buttons up top to open, save and create project files. The 'Verify' button compiles the C code from the project open in the IDE, and 'Upload' compiles and loads the code onto the Arduino, if connected to the computer via USB. You can look at File->Examples to find some sample code to help bring you up to speed.

Step 3: Installing the USB 2.0 Host Shield Libraries

Download the libraries from GitHub by clicking the 'Download as .zip' button, the last button on the right side . Once you have the .zip file, move it to the 'Libraries' folder within the 'Arduino' install folder, extract the files, and remove the '.' from the folder name. Leave the folder here and close your Arduino IDE window, if you have it open. To link the libraries in the Arduino IDE, go to 'Sketch->Import Libraries' and navigate the file window to find that folder. Once that is completed, 'File->Examples->USB_Host_20_Libs' will contain all the code we need to communicate with the USB Host Shield, the Bluetooth dongle, and the DualShock 4 controller. Check out some of the examples, especially the 'PS4BT' example in the 'Bluetooth' folder.

Step 4: Assemble the Hardware

Insert the Bluetooth dongle into the USB Host shield's USB port. Set the USB shield on the Arduino Uno, lining up the correct pins and gently push them together. This little computer will communicate with the controller once we install our code onto it. To connect the Arduino to your computer, use your USB cable. Find

Step 5: Run Your Program!

The example code provided shows how to read input from the controller, I quickly mocked up some code that plays around with the LED on the controller. By pressing the up button on the D-pad, you can switch between changing color based on the gyroscope readings and a right thumbstick plus left trigger combo.

Open led_demo.ino in the Aurduino IDE and click 'Verify' to see that it compiles. Make sure your Arduino Uno, USB shield and bluetooth dongle are assembled and connect it to the computer via a USB. Click 'Upload' and wait for the code to finish writing to the Arduino. Once you see that complete, go to the next step to open a serial terminal.

Step 6: Getting Debug Information Via Serial Terminal

The Arduino creates a serial communication connection to communicate with the host computer. This connection is primarily used to upload compiled code directly onto the Arduino, but it can also be used to display output information as it happens on the board.

PuTTY is a tool that facilitates many types of terminal communication, such as serial communication, a fairly simple protocol. Download PuTTY from the website here. Install and run PuTTY, select 'Serial' underneath 'Connection Type' and select the correct COM port that the Arduino is on. On Windows, to find which COM port your Arduino is on, find the Device Manager (search for it under the Control Panel) and look at the devices listed under COM, one of them should be your Arduino! Now put in the same value for speed that is in your Arduino code ( Serial.begin(115200); is the line that starts a serial connection, default baud rate in PuTTY is 9600).

The Arduino software will not be able to upload any code to your board while there is an active serial connection open, so make sure you exit the serial terminal when you want to update code. Feel free to save your settings in PuTTY to make it easier to quickly open a serial connection.

Once the code is loaded onto your Arduino, open a serial connection to your board. You should see the line 'PS4 Bluetooth Library Started' printed at the top. If not, try hitting the reset button on the board or reconfigure your serial connection to the correct COM port and baud rate.

Step 7: Test Your Program

Only after the serial connection is open will the Arduino connect with the Bluetooth dongle. If you want the Arduino to operate without the connection, just comment out the code initializing the Serial object and any print statements. Once the serial connection is open, the Bluetooth dongle goes into search mode, where it looks for a controller to pair with. Hold the Share and PS buttons on your controller to get the LED to flash quickly in a pattern, this means it is searching for a new connection. If the LED is pulsing, it is looking for a console, simply hold the PS button down for 10 seconds to shut the controller down at any time. If your controller connects successfully, you'll notice the LED holding solid. Shake the controller (carefully!) to watch the gyroscopes alter the color of the LEDs, or hit 'Up' on the D-pad to use the right thumbstick and left trigger to cycle through different colors. Pressing 'X' toggles printing the RGB values to the serial terminal.

That's just a taste of what you can do with the controller, now it's up to you to write your own amazing code!

Step 8: Conclusion

So that's how you connect a PS4 DualShock 4 controller to an Arduino! I tried to cover the basics in case there were readers that were still learning how to use the Arduino, so hopefully it wasn't too bogged down with irrelevant information. Please let me know if there are any errors or changes I should make. Thanks!

Be the First to Share


    • Made with Math Contest

      Made with Math Contest
    • Multi-Discipline Contest

      Multi-Discipline Contest
    • Robotics Contest

      Robotics Contest

    20 Discussions


    Question 5 months ago on Step 6

    Sketch uses 21624 bytes (67%) of program storage space. Maximum is 32256 bytes.
    Global variables use 910 bytes (44%) of dynamic memory, leaving 1138 bytes for local variables. Maximum is 2048 bytes.
    avrdude: ser_open(): can't set com-state for "\\.\COM4"

    is the error I keep on getting.
    Any solutions please?

    miss mechatronics

    Question 1 year ago on Step 6

    can I use the same library for PS4 Thrustmaster T.Flight Hotas 4 and If I can't can you guide me to find the library for it


    Question 1 year ago


    very nice tutorial. But it just doesn't work at my arduino.

    I have:

    - Arduino Uno R3

    - USB Host Shield

    - Bluetooth Dongle

    With the demo in the Bluetooth library and with your led_demo.ino the controller is searching and searching but there is now connection.

    The last state from arduino is "Send HID Control Connection Request" and nothing else happens.

    Does anyone have an idea what I'm doing wrong? Do I have to 'disconect' my controller from my PS4? (PS4 is not available while testing - of course) Does any of the components won't work with this tutorial?


    Question 1 year ago

    Instead of using a USB shield and a Bluetooth dongle, wouldn't it be possible to just use an HC-05 Bluetooth module?


    Question 1 year ago on Step 5

    hi, I downloaded the led_demo.ino file,(it got a completly different name) and when I try to verify it, came back with mistakes in line 19.

    Is it possible that the file get corrupted in any way?

    Thanks for any answer,




    3 years ago

    Can an Bluetooth module such as the HC-06 be used instead of using a USB Shield+Bluetooth dongle?

    3 replies
    Nolan CashAnthonyR138

    Reply 3 years ago

    dont quote me because i dont know if the new tech has changed anything that would let the HC-06 work with it, but i know that it wouldnt work with the older model controllers. in fact only a handfull of dongles would work with the older models. the PS4 has its own dongle made by sony and all ready, ready, already. so thats what im going with and its goig to set you back $25 at best buy

    Nolan CashNolan Cash

    Reply 3 years ago


    the duleshock 4 wireless adapter that I mentioned earlier will not work with the arduino host shield after all....

    NguyenN90Nolan Cash

    Reply 2 years ago

    Really? Is it only work with the Bluetooth module HC-06 instead of the Bluetooth host shield?


    2 years ago

    How can I control the arduino with ps4 console and bluetooth module HC-06? Is it just as same as the article that you have written or not?


    2 years ago

    just want to control 4 servo's do you know who i can do that? wit ps4 controller

    Nolan Cash

    3 years ago

    already got another question....

    in your enxample code you have

    #include <spi4teensy3.h>

    im still a bit new so is that in referance to the dongle and would it be nessisary if i was using the sony brand wireless usb dongle?

    Nolan Cash

    3 years ago

    DUDE!!!! thank you and brace yourself for my onslaught of questions.

    ok so im building a battle bot and while looking for dongles that would work with the PS3 controller i saw the wireless dongle for the PS4 and googled to see if there was a library yet. your instructable was third on google.

    so i read somewhere that the MEGA wont work with the USB host shield 2.0 do you know if that is correct, and with that. do you know if the DUE is compatible?

    so far thats all the questions i have but i apologize in advance because im sure ill have more.


    3 years ago

    I am new to programming, actually new is an understatment. Anyway I was wondering if this could be used to contol a robot, with contols like moving forward and backward and making noise? Any help woukd be appriciated, thanks in advance!

    2 replies

    Reply 3 years ago

    Yes, you would operate off the values given by the controller, turning motors on/off based by buttons/axis values.


    3 years ago

    Hi there,

    Very informative! I am having one issue. I get the line PS4 Bluetooth Library Started and press the share and ps button. The controller flashes but nothing else happens. could you please help me out?

    Kind regards.


    3 years ago


    I am trying to connect the USB dongle from the link above tto a USB HOST SHIELD into a Arduino UNO and my dongle will not detect the controller. The dongle is not flashing. Any advice?


    5 years ago on Introduction

    Hi ! Thanks for your amazing guide , it's exactly what I needed , but there's something I need to know , is it. Possible to use blutooth modules like BLK-MD-SPK-E or any arduino blutooth shields instead of a usb module + a blutooth dongle ? (In case of having space limits.)