DIY Bluetooth or USB HOTAS / Game Controller

by realrobots in Circuits > Electronics

2973 Views, 7 Favorites, 0 Comments

DIY Bluetooth or USB HOTAS / Game Controller

configurator_thumbnail.jpg

To make my own controller I'm going to rely on my rr_configurator software, which can be used with Arduino Pro Micro microcontrollers for USB game controllers and ESP32 microcontrollers if you want bluetooth. It'll make it so once I've wired up my buttons I can map the buttons straight from Windows and never have to do a line of code.

Another benefit is that it allows devices to chain together so I can have my Joystick, throttle and button box all tethered together and reporting to Windows as one device.

I'm going to build this controller using 3D printed parts that are available for download for free on my website realrobots.net but these instructions can be followed just the same if you are building your own controller, or even hacking new buttons and knobs into an existing one. You could even replace the electronics in an old controller and give it new features like bluetooth.

Supplies

Microcontroller(s):

1 x ESP32 Dev Kit if you want bluetooth.

or

1 x Arduino Pro Micro for a USB device (additional Pro Micros for more inputs, 16 per device)

Buttons, switches and/or knobs:

You really can pick almost whatever inputs you like even fancy hall effect sensors if they have a PWM output.

In the examples I'm going to demonstrate some push buttons, 3 pin potentiometers, and toggle switches.

You'll also need some wire to connect your inputs.

Tools:

Soldering iron and solder wire

Maybe pliers, sweezers as well

Gather and Connect Your Inputs

partsExample.jpg
schem_buttons_only_cropped.jpg
schem_full.jpg

In the first picture you can see some of the basic controls you might use, along with the Arduino Pro Micro microcontroller in the middle. In the bottom right is the ESP32 Dev Kit that you can use if you want bluetooth rather than USB connection while playing.

The second picture shows how you would connect momentary switches, of the two pins one will always go to a GND pin on your microcontroller while the other will go to an available numbered pin on your microcontroller. The ground wires all go to the same place so can be daisy chained or each go directly to their destination.

The third picture also shows the connections of 3-pin potentiometers. The two outer pins go to vcc (5v) and GND, it doesn't really matter which way, and the center pin gives the signal which will go to an analog capable pin on the microcontroller. On the Arduino Pro Micro these are pins [4, 6, 8, 9, 10, A0, A1, A2, A3].

Below is a video demonstrating how to solder these connections.

(optional) Tether Additional Devices

I2C_schem_md.jpg
aircraft_plugs.jpg

If you need more than 16 inputs or want to do something cool like have swappable sticks or tethered throttles etc. you can do so by connecting the 5v, GND, SCL and SDA pins of each of the Pro Micros together. I like to do it using aircraft style plugs as in the picture but you use any plug with at least 4 pins or even connect them directly.

If you're using the ESP32 dev kit you can still do this, but you can only have one ESP32 and it must be the master device, connected devices must be Arduino Pro Micros. On the ESP32 dev kit the SCL pin is D22 and the SDA pin is D21.

This connection setup used is I2C and is a "bus", so as many devices as you have will all have their SCL and SDA pins connected in common, when we get to the software we will assign them addresses so they can communicate without conflict.

Aside from the I2C connections, you wire up inputs for the secondary devices the same as in step 1.

Software and Binding

card_software.jpg

Finally you'll need to download the Arduino IDE which you will use to upload the rr_controller firmware.

  1. Download the firmware
  2. Open rr_controller.ino in the Arduino IDE
  3. Pick "Arduino Genuine/Micro" from the tools->boards list
  4. or pick ESP32 Dev Kit from the tools->boards list if you're using an ESP32
  5. Connect your microcontroller to your pc with a USB cable
  6. Choose you connected board in tools->ports
  7. Press Sketch->Upload to upload the firmware to your device

Now that the firmware is on your device you need to download the configuring software rr_configurator that lets you assign what controls are assigned to each input.

In the software you'll get a list of all the possible input pins on your microcontroller. For potentiometers you will need to set the "Pin Mode" to "INPUT" and the "Mode" to "ANALOG". You should see the raw value from your input in the "Raw_Value" column. From the "Assignment" dropdown you can choose which axis you want this to represent in game.

For switches and buttons you want the "Pin Mode" to be "INPUT_PULLUP" and the "Mode" to be "DIGITAL".

Don't forget to press the "Commit to EEPROM", otherwise all your changes won't be remembered after the controller is powered down.

You can test if your inputs are being received by Windows correctly by using the "Set up USB game controllers" function in windows (use the Windows search), choosing your device from the list and pressing "Properties"

If you only intend on using one device you can stop there, if you want to tether multiple ones together you need to change the "Address" to something other than "0" for devices other than the one you intend to have connected via USB. The master device should be address 0, all subdevices should have a unique address from 1-255. You should also give them a name to help differentiate them.

Once devices have unique addresses you'll be able to select them from the "Choose Device" dropdown while connected to the master device at address 0.