Using a USB host shield and a Bluetooth dongle to get data from a PS3 controller – Success!

As mentioned in a previous post, I’m interested in using a PS3 controller as the remote for future projects/robots. Having received all of the required hardware, I decided to make this video explaining the process of setting up the PS3 controller and Arduino for communication via Bluetooth. See below the video for details. UPDATE: The latest USB host library does not print out any debug information, so you won’t see any of the information that is printed out below “Bluetooth Library Started.” You should still be able to connect your PS3 controller and see it’s data output in the terminal.

UPDATE: I have found another place to purchase new dongles: here.

UPDATE: You can buy new dongles (not factory seconds like mine) here.

Hardware (besides an Arduino):

A Sony-made, PS3 controller (Dualshock 3 or Sixaxis (I was unable to find a strictly Sixaxis controller)).

A USB host shield: Circuits@home and Sparkfun.

A Bluetooth dongle: The wiki page for using a PS3 controller will have a list of compatible dongles (although note that in the video I mention that one of the “supported” dongles doesn’t in fact work). Here are the two I have: The black one (working) and the green one (not working, although listed as compatible). These are also confirmed working (by the developers): Kingston and Zoom.

The Software (besides the Arduino IDE):

UPDATE: Some people have had trouble with the newer versions of the USB host shield library. The new library does not print out the debug information you see in my video and the sketch will become too large to upload to an UNO if you turn the debugging on. If you would like to use the exact same version I use in my video (and am still using), you can get it here. You can get the latest version of the USB host shield library below.

You will need to download the entire USB host shield library from GitHub. This is a direct download link, but if you’d like to take a look around the repository go here.

Install the library as you would any other (if you haven’t done this before see this page), and open the “PS3BT” example as I show in the video (File –> Examples –> (Whatever you named the library) –> Bluetooth –> PS3BT). Remember that the Arduino doesn’t allow for dots (.) or dashes (-) in the library folder name, so when you download the library (which for some reason does have dots and dashes in its folder name) you will have to rename for the Arduino IDE to recognize it.

If there is something I forgot to include here, or if you have a question about something in the video, please ask.

152 thoughts on “Using a USB host shield and a Bluetooth dongle to get data from a PS3 controller – Success!

  1. /*
    Example sketch for the PS3 Bluetooth library – developed by Kristian Lauszus
    For more information visit my blog: http://blog.tkjelectronics.dk/ or
    send me an e-mail: kristianl@tkjelectronics.com
    */

    #include
    #include
    // Satisfy IDE, which only needs to see the include statment in the ino.
    #ifdef dobogusinclude
    #include
    #endif

    USB Usb;
    //USBHub Hub1(&Usb); // Some dongles have a hub inside

    BTD Btd(&Usb); // You have to create the Bluetooth Dongle instance like so
    /* You can create the instance of the class in two ways */
    PS3BT PS3(&Btd); // This will just create the instance
    //PS3BT PS3(&Btd, 0x00, 0x15, 0x83, 0x3D, 0x0A, 0x57); // This will also store the bluetooth address – this can be obtained from the dongle when running the sketch

    boolean printTemperature;
    boolean printAngle;

    int motor1 = 3;
    int motor2 = 5;
    int motor3 = 8;
    int val = 0;

    void setup() {
    Serial.begin(115200);
    while (!Serial); // Wait for serial port to connect – used on Leonardo, Teensy and other boards with built-in USB CDC serial connection
    if (Usb.Init() == -1) {
    Serial.print(F(“\r\nOSC did not start”));
    while (1); //halt
    }
    Serial.print(F(“\r\nPS3 Bluetooth Library Started”));
    pinMode(motor1, OUTPUT);
    pinMode(motor2, OUTPUT);
    pinMode(motor3, OUTPUT);

    }

    void loop() {
    Usb.Task();

    if (PS3.PS3Connected || PS3.PS3NavigationConnected)
    // Analog button values can be read from almost all buttons
    if (PS3.getAnalogButton(L2) || PS3.getAnalogButton(R2)) {
    Serial.print(F(“\r\nL2: “));
    motor1.write(map(PS3.getAnalogButton(L2), 0, 255,255, 0));
    if (PS3.PS3Connected) {
    Serial.print(F(“\tR2: “));
    motor2.write(map(PS3.getAnalogButton(R2), 0, 255,255, 0));
    }
    }
    if (PS3.getButtonClick(PS)) {
    Serial.print(F(“\r\nPS”));
    PS3.disconnect();
    }
    else {
    if (PS3.getButtonClick(TRIANGLE))
    Serial.print(F(“\r\nTraingle”));
    motor3.write(map(PS3.getAnalogButton(TRIANGLE), 0, 255,255, 0));
    }
    }

    just need a littlehelp

  2. Hello
    I have been facing issue for setting same address as that of Bluetooth dongle on PS 3 controller . When I turn on shield for first time I get messages till waiting for incoming connection request . That is first 3 to 4 lines . But when I connect my ps3 controller via usb cable for the first time to sheild nothing happens . I have been using dongles that looks same as that of yours in video .
    I need your help with one more issue . I don’t know how to interface ps3 controller just via usb cable that is using ps3 usb . I need step wise guide . I have arduino mega 2560 also , is it possible to connect usb host shield for Uno to it ?
    Kindly expects help !

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s