PS3 Dualshock Controller – USB Host

The USB PS3 Dualshock Controller Software allows you to connect a PS3 Dualshock Controller to the USB Host Board and read the analog stick inputs, button presses, accelerometer and button pressure using I2C or serial TTL

You can also set the four LED’s and turn on the rumble motors.

This is a free software download for our USB Host Board and USB Host IC’s (SOICDIPSSOP).

Please note: This software is free to download but only works on one of our USB boards or chips which must be bought separately.
To order, simply select which of our boards or IC products you wish to have the software loaded onto. See the USB Host Board and IC product pages for details onĀ pricingĀ and installing this software.

The USB PS3 Dualshock Controller software for our USB Host board allows you to easily read the analog joysticks, accelerometer, button pressure values and all the buttons from a PS3 Controller. You can also set the 4 LEDS and the rumble motors. Output from the host board is via serial (mainly for testing) and also via I2C. Now you can easily interface this versatile PS3 Game Controller into virtually any Microcontroller project.

Use it to control

  • A Robotic Arm and grabber (robot claw)
  • Wheeled or tracked vehicles
  • Your own Arcade game on a Raspberry Pi

Configuration Settings

Configuration can be done by sending commands via the serial port. Either by microcontroller or via a terminal program and a suitable serial TTL connection. Commands take effect immediately and are stored in Eeprom on the board.

The following Commands are available.

SERIAL <value>Set Serial Output ON/OFF
[ON|OFF]
HEX <value>Set Serial Hex Output ON/OFF
[ON|OFF]
BAUD <value>Set Serial Port Baud Rate
[2400|4800|9600|14400|19200|38400|57600|115200]
I2C <value>Set I2C Address
[1-127]

BAUD Rate

The USB Host board will communicate over serial TTL at the following baud rates

  • 2400
  • 4800
  • 9600 (default)
  • 14400
  • 19200
  • 38400
  • 57600
  • 115200

The default baud rate is 9600

SERIAL

SERIAL turns on or off the output of serial data when the PS3 controller is plugged in. Data is output in ASCII text format.
Turn it on for testing the PS3 controller or if your want the serial data. Turn it off when using I2C communication to save on processing.

HEX

The HEX option converts the SERIAL output into single Hexadecimal bytes and adds a CRC checkdigit. It reduces the amount of data transmitted and makes it easier to process at the receiving device. It is very useful for transmission of the data via XBee to a remote device.

I2C Address

The I2C default address is 41. This can be changed to any value between 1 and 127 using the I2C command

HELP

Help can be displayed at any time by typing ? or HELP

The current settings for SERIAL and I2C address are displayed.

?

USB Host Ps3 Dual Shock Controller v1.02

  SERIAL <value>          - Set Serial Data Output On/Off
   (OFF)                  - [ON|OFF]
  HEX <value>             - Set Serial Data Output Hexadecimal On/Off
   (OFF)                  - [ON|OFF]
  BAUD <value>            - Set Serial Port Baud Rate
                            [2400|4800|9600|14400|19200|38400|57600|115200]
  I2C <value>             - Set I2C Address
   (41 )                    [1 - 127]
  HELP or ?               - display help

Reading the Data

As mentioned, there are two ways to obtain the PS3 data from the USB Host board. Either by simple serial output or by using I2C communication. Although the serial output is meant primarily for testing the controller, the HEX output has a useful purpose if you want to transmit the data wirelessly (e.g. to control a UAV or robot) as it can be fed directly into an XBee radio (or similar) for easy transmission.

Serial Data Output

Serial data output looks like the following

PS3,129,128,128,128,90,94,0,0,0,0,0,0,0,0,0,0,0,0,00000000000000000

It conforms to the same format as the I2C data table shown below. Joystick and pressure outputs are comma delimited, whilst the button presses are not. each line is terminated with a CRLF.

HEX Serial Data Output

This is similar to the Serial data output, but each value is output as a single hexadecimal value and there are no comma delimiters. Additionally there is an extra CRC8 checkdigit added to the data to enable the data to be checked for errors. The HEX output is useful for transmission via XBee radio to remote devices.

The data is in the same format as the I2C data table shown below and transmitted as single bytes. Each transmission is prefixed by characters “PS3” and ended with CRLF.
A total of 41 characters is transmitted ( 3 for PS3, 35 data, 1 CRC, 2 for CRLF)

There is a link to an example Arduino program for reading the HEX data at the bottom of the page.

I2C Data Output

I2C data can be read in the normal I2C manner using the following register values for obtaining data. Data can be read on one complete go or read individually. There is a link to an example Arduino program for reading the data at the bottom of the page.

RegisterDescription
0Left Joystick X
1Left Joystick Y
2Right Joystick X
3Right Joystick Y
4Accelerometer X (0-255) 128 center
5Accelerometer Y (0-255) 128 center
6Pressure UP
7Pressure RIGHT
8Pressure DOWN
9Pressure LEFT
10Pressure LB
11Pressure RB
12Pressure LT
13Pressure RT
14Pressure Triangle
15Pressure Circle
16Pressure X
17Pressure Square
18Button LEFT
19Button DOWN
20Button RIGHT
21Button UP
22Button START
23Button Right Joystick
24Button Left Joystick
25Button SELECT
26Button SQUARE
27Button X
28Button CIRCLE
29Button TRIANGLE
30Button RT
31Button LT
32Button RB
33Button LB
34Button PS3

Registers for setting LEDs and Rumble motors..

RegisterDescription
50Rumble Motor Control
1 – Soft Rumble
2 – Short Heavy Rumble
3 – Long Heavy Rumble
51LED Control
Control the 4 LEDs by sending a single BYTE. Bits 0 – 3 controll the 4 LEDS
E.G  00000101 turns on LEDs 1 and 3

Documents and Links

Arduino Example program for Reading data via I2C
Arduino Example program for Reading HEX serial data

Differences between PS3 Controllers

You can buy genuine Sony PS3 Controllers or you can buy cheap knock-offs on ebay. There are pro’s and cons to both which i will list here

Genuine Sony PS3 Controller

Pro’s

  • All Features available
  • Pressure sensitive button output
  • Accelerometer outputs
  • Rumble motors
  • Quality Joysticks using full movement range

Cons

  • Not cheap
  • Bluetooth connectivity unavailable at present

Non-branded Controller

There may be some different non-Sony controllers available but the one i bought from ebay was advertised widely by a number of vendors and represents a typical cheap controller. Check with the vendor before purchase that it has all the functionality.

Pro’s

  • Cheap
  • Comes with Bluetooth Dongle so wireless works straight away

Cons

  • No Rumble Motors fitted
  • No Accelerometer output
  • Limited or no pressure sensitive output
  • Inferior Joystick control. Max and min outputs occur at only half stick movement and there is a deadband in the center position

In Summary

If you want a cheap wireless controller for joystick and buttons control, the cheap ebay items are ok. If you want the full features, quality stick movement, rumble motors, pressure sensitive button output and accelerometer output then the genuine Sony product is the one

Shopping Basket
Scroll to Top