With provided code (complete of source) and schematics of the Joystick BitPack™ your ORbit16™ becomes a fully functional Joystick/Gamepad with following features:
- Is recognized by pc as a common HID Joystick
- Additional UART data input/output (57600,n,8,1) for use the joystick with your robot!
- 2 analog axis
- 8 pushbuttons
- reset button
Provided code gives also some useful examples:
- how to enable pullup resistors on digital inputs (CNx pins)
- how to read 2 analog inputs and make the average on 8 readings
- how to translate analog reading (0-1023) to values 0-255 required by joystick
- how to mix HID USB code with UART
ORbit16™ can be programmed using bootloader with this BitPack™ mounted on, since on the board there is the reset button and the switch S7 is parallel with S2 on the ORbit16™ board.
Board is single-sided, only 2 bridges on top are required, so is very easy to make the Joystick BitPack™ at home!
Bill of Material
- 1x thumb joystick (you can buy it from Sparkfun or Robot-Italy)
- 4x tactile switch 12x12mm (you can buy them from Sparkfun or Robot-Italy)
- 4x tactile switch 6x6mm
- 1x led 3mm
- 2x 20-pin male header
- 1x 330Ω resistor ¼W
- 1x 560Ω resistor ¼W
- optional 4-pin male header or 4-pin polarized connector for UART connection (Sparkfun or Robot-Italy)
How does it works
When you connect the ORbit16™ with Joystick firmware loaded and Joystick BitPack™ mounted on, is recognized by pc as a common HID Joystick so you can use it for play with your games (Here is a video showing Joystick BitPack™ usage with M.A.M.E.).
Additionally, the header named JP1 reports GND, +3.3V and UART RX/TX. Using the joystick on UART TX (57600,n,8,1) you can read the joystick values:
X:127 Y:127 B:128
X is the value for analog X-axis (≈127: center, >127:right, <127:left). Y is the value of analog Y-axis (≈127: center, >127:down, <127:up). B is the value of pushbuttons. Each pressed button has a bit in an 8-bit value: S1 is on BIT0 (value:1), S2 is on BIT1 (value:2) and so on up to S8 – BIT7 (value:128). If B=129 so S8 and S1 are pressed.
USB and UART works simultaneosly so you can use only one firmware for use your ORbit16™ Joystick with the PC or to control your robot!
The joystick has a pushbutton that is activated by pressing down the stick, this button is S8.
Following video shows how does Joystick BitPack™ works
On the top is a software used for joystick testing, on the bottom is HyperTerminal.
Download includes PDFs of the board, source code with MPLAB project and compiled HEX. Code for PIC24FJ64GB002. Joystick BitPack™ to be mounted as shown in the photo above.