The combined USB PS3 and PS4 Dualshock Controller Software allows you to connect either a PS3 or PS4 Dualshock Controller to one of our USB Host Boards and read the analog stick inputs, button presses, accelerometer and touchpad using I2C or serial TTL.
It’s time to give up your RC Transmitter with its limited number and type of controls and use the versatile PS3 or PS4 Game Controllers for your robotics project. With the use of a compatible Bluetooth Dongle you can now connect to your PS3 or PS4 Controller wirelessly using the built-in Bluetooth. This makes using a PS3 or PS4 controller as the basis for your robotics project very easy to implement.
This is a free software download for our USB Host Board and USB Host IC’s (SOIC, DIP, SSOP).
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.
This new version of the Playstation software combines our existing PS3 software with the PS4 software into one integrated solution. Easily change from PS3 to PS4 and vice versa without having to upload new software.
Features
- Bluetooth Connection to following controllers
- PS3 Dualshock
- PS3 Move Navigation Controller
- PS4 Dualshock controller
- Easily Pair with Bluetooth Dongle
- Serial communication at baud rates 2400, 4800, 9600, 14400, 19200, 38400, 57600, 115200
- I2C communication
- PS3/PS4 Bluetooth has a range of approx 50m
- PS3 / PS4 Controller has
- 8 Analog Outputs (Joysticks, Accelerometer, Triggers)
- 18 buttons
- PS4 Controller has additional
- X/Y Trackpad Analog Output
Use it to
- Control a Robotic Arm and grabber (robot claw)
- Control wheeled or tracked vehicles or robots
- Replace an RC Radio system
- Control all features of an R2D2 droid
Synching with your PS3 Controller
Just as with any bluetooth connection, the Bluetooth Dongle and your PS3 Controller have to be synched in order to communicate. With the PS3 controller, this is not done using the usual 4-digit passkey method. Instead, it is done by storing the Bluetooth Address of the dongle into the PS3 controller.
NOTE: The software needs to know what type of controller is connected and the default is for a PS4 controller. This will need to be changed to PS3 in the configuration settings (see below)
Synching the PS3 controller with the bluetooth dongle only needs to be done once.
Our code makes synching very straightforward; just follow these steps.
- Power up the USB Host board
- Plug the Bluetooth dongle into the USB Host board. The Bluetooth Address will be read and stored on the USB Host board
- Unplug the dongle and plug in your PS3 controller using a USB cable. The bluetooth address will now be sent and stored in the PS3 controller.
- Unplug the PS3 controller and plug the Bluetooth dongle back in. Press the power button on the PS3 controller.
- The LED’s on the PS3 controller will flash for a few seconds, then LED1 will go solid red and the motors will rumble briefly – you are connected.
Synching with your PS4 Controller
Just as with any bluetooth connection, the Bluetooth Dongle and your PS4 Controller have to be paired in order to communicate.
Pairing the PS4 controller with the bluetooth dongle only needs to be done once.
Our code makes pairing very straightforward; just follow these steps.
- Power up the USB Host board with the Bluetooth Dongle plugged into the USB socket
- Blue LED should be flashing
- Briefly connect either the SDO (A) or SS pin to GND
- Blue LED should be flashing FASTER
- Press and hold the PS4 and Share buttons together on the PS4 controller until the PS4 led starts flashing.
- The units should now pair and connect.
When connected the motors will rumble and the LED will turn solid blue (default)
Reading the Data
As mentioned, there are two ways to obtain the PS3/PS4 data from the USB Host board. Either by simple serial output or by using I2C communication. Although the standard serial output is meant primarily for testing the controller, the serial 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.
The default settings are for Serial Output ON and Hex ON. For testing purposes it is recommended to turn the Hex output OFF first.
Serial Data Output
The Serial data output (non-hex) is designed for testing purposes and is human readable in decimal values.
For decoding using a microcontroller, use the fixed format HEX output instead
The Serial Data output looks like the following
PS4,129,128,128,128,90,94,0,0,000000000000000000,0,0,0\r\n
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 fixed format, so specific data is always in the same position. This makes it great for decoding with a microcontroller and useful for transmission via XBee radio to remote devices.
Each transmission is prefixed by characters “PS4” and ends with CRLF.
A total of 20 characters is transmitted ( 3 for PS4, 8 bytes of analog data, 3 bytes for buttons, 2 bytes trackpad data, 1 Battery Voltage, 1 CRC, 2 for CRLF)
Byte | Description |
Header (3 bytes) | |
1 | “P” |
2 | “S” |
3 | “4” |
Analog Data (8 bytes) | |
4 | Left Joystick X |
5 | Left Joystick Y |
6 | Right Joystick X |
7 | Right Joystick Y |
8 | Accelerometer X |
9 | Accelerometer Y |
10 | L2 |
11 | R2 |
Buttons (3 chars) | |
12 bits 0-3 | Compas Pad Button Press These 4 bits are treated as a item with the following value 0 = N 1 = NE 2 = E 3 = SE 4 = S 5 = SW 6 = W 7 = NW 8 = No button pressed |
12 bit 4 | Square |
12 bit 5 | X |
12 bit 6 | Circle |
12 bit 7 | Triangle |
13 bit 0 | L1 |
13 bit 1 | R1 |
13 bit 2 | L2 |
13 bit 3 | R2 |
13 bit 4 | Share |
13 bit 5 | Options |
13 bit 6 | L3 |
13 bit 7 | R3 |
14 bit 0 | PS4 |
14 bit 1 | TPad |
Trackpad (2 chars) | |
15 | TPad X |
16 | TPad Y |
Battery (1 char) | |
17 | Battery Voltage (values from 0-15) |
Footer (3 chars) | |
18 | CRC Checksum |
19 | \R |
20 | \N |
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 in 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.
When using the I2C connection we recommend turning the serial output off (“SERIAL OFF”) as the overhead in formatting the serial data can cause timing issues with I2C.
I2C Register | Description |
Analog Data | |
0 | Left Joystick X |
1 | Left Joystick Y |
2 | Right Joystick X |
3 | Right Joystick Y |
4 | Accelerometer X |
5 | Accelerometer Y |
6 | L2 |
7 | R2 |
Buttons | |
8 bits 0-3 | Compas Pad Button Press These 4 bits are treated as a item with the following value 0 = N 1 = NE 2 = E 3 = SE 4 = S 5 = SW 6 = W 7 = NW 8 = No button pressed |
8 bit 4 | Square |
8 bit 5 | X |
8 bit 6 | Circle |
8 bit 7 | Triangle |
9 bit 0 | L1 |
9 bit 1 | R1 |
9 bit 2 | L2 |
9 bit 3 | R2 |
9 bit 4 | Share |
9 bit 5 | Options |
9 bit 6 | L3 |
9 bit 7 | R3 |
10 bit 0 | PS4 |
10 bit 1 | TPad |
Trackpad | |
11 | TPad X |
12 | TPad Y |
Battery Voltage | |
13 | Battery Voltage (values from 0-15) |
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.
DEVICE <value> | Select Playstation controller that will be connected [PS3|PS4] Default: PS4 |
SERIAL <value> | Set Serial Output ON/OFF [ON|OFF] Default: ON |
HEX <value> | Set Serial Hex Output ON/OFF [ON|OFF] Default: OFF |
BAUD <value> | Set Serial Port Baud Rate [2400|4800|9600|14400|19200|38400|57600|115200] Default 9600 (we recommend using 115200) |
I2C <value> | Set I2C Address [1-127] Default: 41 |
RGB <value> | Set PS4 LED RGB value when connected (PS4 only) Default 0000A0 |
SYNC | Display SYNC how-to information for specified controller |
DEVICE
This setting allows you to specify whether a PS3 or PS4 controller is to be connected
The default is PS4
BAUD Rate
The USB Host board will communicate over serial TTL at the following baud rates
- 2400
- 4800
- 9600
- 14400
- 19200
- 38400
- 57600
- 115200 (default)
The default baud rate is 9600, but we recommend using a faster baud rate of 115200
SERIAL
SERIAL turns on or off the output of serial data when the PS3/PS4 controller is plugged in. Data is output in ASCII text format.
Turn it on for testing the connected 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.
RGB
Set the PS4 LED colour once connection is made. Enter 6 digit hexadecimal value for Red, Green and Blue portions
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 & PS4 (Bluetooth) Dual Shock Controller v1.00
DEVICE <value> - Set PS3 or PS4 device to connect to
(PS4) - [PS3|PS4]
SERIAL <value> - Set Serial Data Output On/Off
(ON) - [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]
RGB <value> - PS4 LED RGB value (6 digit hex. e.g. 00FF00)
(0000A0)
SYNC - display SYNC information
HELP or ? - display help (this page)
Compatable Bluetooth Dongles
To connect with the PS4 controller you need a Bluetooth dongle that supports high speed data and EDR.