top of page

Arduino Components

- Encoders

Wiring And Basic Tutorial for Mobiflight & Prosim using Arduino Mega

Rotary encoders are devices that convert rotary shaft motion into digital output. They can be turned in both clockwise and anti-clockwise directions without any limits. These simple units typically have five pins: two for ground, two for left and right movement, and one for the push switch.


KY-040 encoders have a PCB attached to the encoder with dedicated de-bounce hardware. However, these require a 5V power supply. Over the years, Mobiflight has evolved and replaced this extra hardware with software debounce within the Mobiflight software. Therefore, you can connect the encoder directly without needing the oversized PCB without any additional hardware.


It is important to note that these components are widely used in simulations. They come in various forms, but there are a few specific points of interest to consider when purchasing them.

1) Shaft type: D-Section or Splined

2) Shaft Length - The longer, the better, usually. 20mm seems ideal for most applications.

3) Does it have a nut and thread? To enable it to be secured it to the panel

4) Does it have a Push button function? Three legs normally have no push. Five legs gives a push function. 

Encoders - KY-040


I began using KY-040 boards, equipped with a de-bounce circuit that enables the Arduino to take accurate measurements and avoid false readings. The number of detents may vary depending on the supplier, but counting them is a simple task.


These boards can be mounted using either the locking nut located on the center shaft or by attaching them to the PCB via the two screw holes.



Encoders - KY-040 WIRING

In this example, the pictures show a KY-040 encoder with PCB. This is simple to wire up with 4 or 5 wires depending on if you need the push switch connected. In these pictures i have missed the switch/button out.

Ky-040 boards differ from single component encoders by requiring a 5v power supply. This can be achieved using an external power supply or by using the 5v out line of the Arduino as shown.

If an external power supply is used, you must connect the grounds together.

arduino single encoder.PNG
Ky040 WD.png

Encoders - Single

I've decided to switch from using KY-040 boards to standard single-component encoders.


When installed in panels, the KY-040 boards require extra wiring and space that can interfere with other components.


I've found that the single-component encoders offer a smoother feel and a definitive click as it moves around its axis. They only require three wires to operate, or four if you want to add an internal switch, and don't need an additional power supply.


MobiFlight software handles the de-bouncing. These components are also smaller in size and easier to install. One side of the encoder has three pins labelled Left, GND, and Right, while the other has two pins labelled GND and SW.

5 pin encoder.PNG

Encoders - Single Component Wiring 

EC11 WD.png

The single encoder can be used with out the debounce circuitry. Mobiflight is ever evolving and has the ability to be able to connect encoders directly.

This time 3 or 4 wires are required depending if the switch/button is required. The ground must also be daisy chained across to the other side.

Encoders - Dual Axis

Dual Encoders.PNG

There are two main options here:

1) The first is from Propwashsim

Fantastic miniature dual encoders complete with PCB and Knobs. This match perfectly the knobs of modern avionics such as Garmin. I tend to use them without the PCB, which significantly increases the component footprint.

2) The second is the EC11 version. These components are ideal for attaching to PCBs as they usually do not have a threaded section for nut attachment. Additionally, you will need to provide your custom knobs. However, they are more affordable and have a pleasant tactile sensation. Furthermore, they come equipped with a push-button function.

Screenshot 2023-12-31 172549.png

Encoders - Multiple Devices

To add multiple KY-040s, you must Daisy chain the power (5v) and the GND. All the other lines/pins require dedicated pin allotment on the Arduino. 

Using Multiple Ky-040 Boards may require an external power supply. This will become especially apparent if you drive seven-segment displays from the same Arduino. As the power drops when an encoder is turned, the 7-segment displays usually change to display gibberish. 

Only the ground needs to be daisy-chained to add multiple encoders (single units).

Wiring 2 KY040 to Arduino.jpg
Wiring Dual Encoders.png
Schematic_Ky040 Multi_2023-12-31.png
Schematic_EC Multi Enc_2023-12-31.png
bottom of page