When flying the flight simulator, quick camera switching is needed. And one good way of doing this is to assign buttons on the yoke or flight stick. I am flying a Boeing 737, hence using the yoke. But the yoke has much fewer buttons than I actually need during a flight. So i played around with a box in my head, where I quickly could select the camera angles.
Connecting the flight simulator with Arduino
I stumbled on an Arduino joystick library by MHeironimus, which could give me the interface between external buttons and the flight simulator. So I ordered an Arduino Micro online.
I imagined my camera selector with 30 buttons, but the Arduino Micro only has 18 usable pins. So I found a really nice library called keypad.h by Mark Stanley and Alexander Brevig, where one can make a matrix of buttons, using fewer control pins.
The keypad library can be installed from the Arduino IDE Library Manager, if using a never Arduino IDE.
Joystick library can be installed by downloading the ZIP file from HERE and importing the ZIP file by selecting “Sketch” / “Include Library” / “Add .ZIP Library” and click “Open” to select the ZIP file.
I edited some of the demo files to support my hardware design. You can download my Arduino sketch HERE.
3D printable box
The next part was the physical box. I like simplicity, so my switch of choice is often a simple pushbutton that can be mounted with a nut and soldered on the back. I designed a box using the following parts:
- Bottom (the enclosure hiding the electronics)
- Top (where the switches are mounted)
- Front (the visible front where the text is located)
- The buttons
If using a 3D printer and time is important, the bottom and top can be printed with 0.4mm nozzle, and the front and buttons can be printed with 0.25mm nozzle. This gives a good value between speed and quality.
Connecting the switches
On the backside of the top, I mounted a solderless breadboard using double adhesive tape, and jumper cables for the connection.
The matrix is build up the way that on each switch, one pin is connected to a red line, and one pin is connected to a yellow line. So every time a switch is pressed, two Arduino pins are activated. By this approach, it is not possible to press more than one switch at a time. But as it is a camera selector only one selection per time is necessary.
The leftmost row is connected to Arduino pin 14, the next row to pin 15, and so forth. Same in the other direction, the top column is connected to Arduino pin 16, the next to pin 10, and so forth. The matrix has 6 rows and 5 columns, making it 6×5=30 switches.
Assigning the buttons
When seeing the case from the front, the upper left corner is switch 1. Going downwards in this row is 2, 3, 4, and 5. Then starting the next row 6, 7, 8, 9, 10, and so forth.
Depending on the flight simulator used, the approach is different. I fly X-plane, and this is how you set it up if you use the same simulator:
X-plane joystick mapping
In X-plane 11 the location of configuration is SETTINGS / JOYSTICK.
First, select the Arduino device from DEVICE.
Then under BUTTONS, locate the buttons from the camera selector box.
Click EDIT beside each button, and select the action that each button must take.
Building the camera selector
To build the flight simulator camera selector box, you will need the following:
- Arduino Micro
- 30x momentary push switches
- 3D print filament
- 4x M3 countersunk hex screws ~20mm.
- Go to Thingiverse and download STL files
- Print the 3 units and the buttons
- Mount the switches
- Solder the switches and connect to the Arduino
- Upload the INO file to Arduino IDE and upload firmware
- Configure the buttons in your flight simulator