You're reading ...
Arduino, Hardware, Software

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 (download link here).

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 (also see the video below):

  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 here 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.

The video shows the steps to take to upload the software to your Arduino Leonardo.

About RudyB

Hobbyist

Discussion

2 thoughts on “A super smooth Joystick and Throttle part 3: wiring and software (with download)

  1. A very interesting and useful project. I am wanting to make a simple throttle only for a space sim (Elite Dangerous) using a 10 slider pot. I have your sketch working on a Leonardo but a couple of questions. As I am using only 1 analogue input and possibly 1 digital input can I still use the sketch as is and just ignore the random noise on the other inputs or do I need to edit the sketch for only the inputs I am using.

    I am hoping to use a Pro Micro Arduino in the finished project as the Leonardo is too big for this purpose, it’s on a breadboard at the moment. I believe the Pro Micro is Leonardo based so can you envisage any probelms.

    Like

    Posted by Rob | October 29, 2019, 12:42

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

Archive of all posts

Categories

%d bloggers like this: