Home

Latest Post

A super smooth Joystick and Throttle part 3: wiring and software (with download)

This is part 3 of 3 on building your own ‘super smooth’ joystick and throttle that can be used with flight simulators or racing games.

  1. The final result and the components needed.
  2. The woodwork, a Fusion 360 model and drawings with dimensions.
  3. The wiring and the software, with a download link of course.

An Arduino Leonardo is the heart of the system. It reads out the push buttons, switches and potentiometers and it sends the data via USB to the PC. Beware … a standard Arduino UNO won’t work … a Leonardo has a different kind of Atmel chip on board, one that connects to USB in a way that makes it possible to function as a HID (Human Interface Device), which is needed for this application. A Leonardo can be acquired here.

The wiring.

The list below shows all connections to be made.

All pushbuttons are connected to GND at one side. The three way toggle switch has GND in the middle. The potentiometers are connected to 5V and GND on the outsides and the slider / rotator go to pins A0-A3. The rotary encoder also needs 5V and GND, its noted on the connector which pin is witch.

Leonardo_ICSPA0 joystick X
A1 joystick Y
A2 joystick Z
A3 throttle slider pot
A4 rotary encoder CLK
A5 rotary encoder DATA
0 do not use, it is needed for USB
1 do not use, it is needed for USB
2 pushbutton 1
3 pushbutton 2
4 pushbutton 3
5 pushbutton 4
6 pushbutton 5
7 pushbutton 6 (on top of the joystick)
8 pushbutton 7
9 pushbutton 8
10 pushbutton 9
11 pushbutton 10
12 pushbutton 11 (rotary encoder)
13 LED
MISO three way toggle switch up
SCK three way toggle switch down

The LEDs at the bottom of the Joyctick and Throttle are connected to 5V and GND, with the resistor in between of course. Take care the long leg goes to the 5V. They show there is power. The third LED long leg = pin 13 … it lights when a button is pressed.

blog_throt_img_bottom   blog_joy_img_bottom

My joystick and throttle do not look very tidy … but all wires are firmly connected. I always do a ‘pull check’ and a resistance measurement immediately after soldering every wire to assure all is OK before I go on.

The software.

First of all many thanks go to M. Heironimus for making his Arduino USB HID library publicly available. It is thanks to this library that the software effort to make things work was minimal.

The joystick X,Y,Z axis are configured as 10 bits, running from -511 to +511, with an S-curve for very fine control around the middle.

The throttle linear pot is configured as 10 bits, running from 0 to 1023.

The rotary encoder is configured as an analog axis with an 8 bits range of -127 to +127. Pressing its switch will set it to zero. To avoid having to turn it many times to get to the limits, during calibration in FSX or X-plane you can press the encoder switch and button 9 or 10 simultaneously to quickly go to limit values. I use it for pitch trim up / down, it gives a nicer feel than using push buttons for pitch trim.

Follow these steps to upload the software to your Arduino Leonardo:

  1. Visit the Arduino website and follow instructions to install the Arduino IDE software on your PC.
  2. Start up the IDE and go to File > Preferences to tell where you want to store your ‘sketches’ (‘sketches’ is the Arduino name for programs). Close the IDE again.
  3. Download the joystick software and unzip it.
  4. Copy or Move the ‘Joystick’ folder to your Arduino/libraries folder. (Depends where you installed it … default is C:\Program Files (x86)\Arduino)
  5. Copy or Move the RBO_Joystick folder to your sketches folder.
  6. Restart the IDE and open the RBO_Joystick.ino sketch.
  7. Upload the sketch (the arrow icon at the top left).

Control_PanelConfiguration

If needed, disconnect and reconnect your USB cable to the PC … the PC should now recognize the Leonardo as a HID. It can be tested via the Windows Control Panel > Printers and Devices.

If your joystick is recognized it is now time to start FSX or X-plane and go to the ‘settings’ to configure your joystick and throttle axis and buttons.

A video will be here soon!

Advertisements

Welcome at this website / blog

This website / blog contains all kinds of info on the model railway hobby project I'm working on.

The homepage is where new posts appear every time a step has been made, or when I came across something noteworthy.

The other pages, reachable via the topmenu or via the sidebar, store some information I thought worthwhile to remember. Having it all here in one place makes it easy to find it back.

The railway hobby to me is more about electronics and (micro) computer control than about being protypical or to have the nicest scenery. A lot can be found here on the use of Arduino as a DCC decoder and on Traincontroller PC layout control. Who knows these pages may be helpful not only to myself, but also to other model train hobbyists..

Ruud.

Advertisements