USB Host Board - Joystick Software
The USB Joystick Software allows you to connect a USB Joystick to the USB Host Board and read the analog stick inputs and button presses using I2C or serial TTL
Please note: This software is free to download but only works on one of our USB boards or chips which must be bought separately (see below).
Click Here to Download (Version 1.10)
USB Host Boards
USB Host IC's
The USB Joystick software for our USB Host board allows you to easily read the analog stick inputs and all the switch inputs from a USB Joystick. This can give you much more functionality than a traditional Radio Control system and it is much easier to access the control inputs directly in a microcontroller.
Use it to control
- A Robotic Arm and grabber (robot claw)
- Wheeled or tracked vehicles
- Your own Arcade game
All the analog stick and button presses are available using either standard serial TTL or via I2C communication. I2C makes for an easier interface to implement directly from a microcontroller but serial TTL is a good choice if you want to use the joystick as a remote control device sending signals wirelessly.
Axis and Buttons
Not all joysticks are the same. Some joysticks have only basic X and Y axis and a few buttons, whilst some have many more axis of movement and many more buttons. The software will identify all the major axis and buttons/switches used. The axis and buttons possible are
The best way to see which axis and buttons are available, is to monitor the serial output. Move the joystick around and click each button and note which value changes.
The serial output corresponds to the axis and buttons above with the axis displayed in order first, followed by the buttons. The last two entries are the joystick manufacturer VID and PID.The output is comma delimited and the format looks like the following
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.
Set Serial Port Baud Rate (default 9600)
Set Scale for analog joystick inputs
Set Serial Hex Output ON/OFF
Set I2C Address
The USB Host board will communicate over serial TTL at the following baud rates
- 9600 (default)
The default baud rate is 9600
SCALE sets the maximum value for the joystick axis. The default is 255.
With the joystick in the center position the output will be half this value.
This feature allows you to alter the output to match your controlling program. This is useful for instance if you are directly controlling servo's from an Arduino board as the SCALE setting can be set to 180 to give an output of 0 - 180 with 90 being the center position. This directly creates the values needed for the Arduino Servo commands.
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.
The I2C default address is 41. This can be changed to any value between 1 and 127 using the I2C command
Help can be displayed at any time by typing ? or HELP
The current settings for SCALE and I2C address are displayed.
? USB Host Joystick v1.06 BAUD <value> - Set Serial Port Baud Rate [2400|4800|9600|14400|19200|38400|57600|115200] SCALE <value> - Set XYZ Scale value (255) [10 - 255] HEX <value> - Set Serial Data Output Hexadecimal On/Off (ON) - [ON|OFF] I2C <value> - Set I2C Address (41 ) [1 - 127] HELP or ? - display help
Connections required for Joystick Software
- 5V power in
- RX/TX (for setting baud, scale factor and changing I2C address only)
For sending output to a microcontroller, either (or both)
Reading the Joystick Data
Serial Connection (TX)
Everytime the joystick is moved, or a button is pressed or released a text string is sent via the serial port in the following format
The output corresponds to the axis and buttons listed above with the axis displayed in order first, followed by the buttons. The last two entries are the joystick manufacturer VID and PID. The output is comma delimited.
This serial transmission is useful for testing and for transmission via wireless connection
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 transmitted in the format shown below.
A total of 18 characters is transmitted
You can request all of the data items or individual items or groups of items.
Data is stored in registers numbered from 0 through 26
As per normal I2C practice, issue a write command and send the starting register address, then issue a read for the data that you require.
An example Arduino sketch is shown below and should be easily modifyable for other languages.
To upload the Software to the USB Host Board you will need to use the ds30Loader program. See the USB Host Board product page for more information on this.
See the Joystick Software in action
The following video shows a joystick connected to the Magician Robot Chassis and a Robot Claw
Example Arduino code
USB Host - USB Joystick Software
- Manufacturer: HobbyTronics
- Product Code: USBHOST-JOYSTICK
- Stock Quantity: 1
- Ex Tax: £0.00