Example Landing Gear Lights with SimConnect Events - MobiFlight/MobiFlight-Connector GitHub Wiki

Setting up landing gear lights with SimConnect Events

In this tutorial we will learn how to setup the landing gear indicator lights in Mobiflight using SimConnect events.

There is a great video tutorial in the Mobiflight Youtube Channel on this topic:

Landing Gear Switch and Lights for MSFS2020

Landing gear indicators usually have LEDs to display the status of how the landing gear position is. One to three (usually red) LEDs indicate when the landing gear is moving up or down and is unsafe to land; and another set of one to three (usually green) LEDs that indicate when the landing gear is fully extended and it is in safe position to land. When all leds are off, the landing gear is fully retracted.

For this tutorial, you will need to setup three red LEDs and three green LEDs connected to your arduino board. Be sure to connect a 220 to 500 ohm current limiting resistor in series to each LED. Resistors can be connected to either lead of the LED. We have shown them connected to the positive lead for this example. It is a good practice when working with LEDs to check which is the positive lead by connecting a small 3v coin battery to each LED before doing any soldering. Connect the positive lead (usually the longer leg) of each LED to a digital pin in the Arduino board. Make note of the pin number where each LED is connected. Connect the negative lead of each LED to the common ground pin of the Arduino. See the simplified diagram.

image

For this tutorial, we assume that you have already loaded the Mobiflight firmware to your Arduino board. If not, please refer to the tutorial on how to install the firmware.

Create the LED devices in your Mobiflight module

Let's proceed with creating the devices in your Mobiflight module configuration by pressing the Mobiflight Modules button in the main screen.

image

In the Mobiflight Modules window, all the MF modules currently connected and recognized will be listed. Select the board where you have connected your LEDs. Press the "Add Device" button at the bottom of the window. A drop down menu will open with all the different type of devices that can be configured. Select "LED / Output". This will create an LED output device named "Output" in the list of devices of the selected module. Now select this device.

image

Once the device is selected, a device configuration window will open. You can rename the device to something more meaningful. Let's call it "Red LED 1". In the Pin Settings box, select the pin number where you previously connected the first red LED. You will also notice that the name "Output" in the device list has been replaced with "Red LED 1". You are doing well!

image

Now, please repeat the same device configuration procedure for the other five LEDs. We won't go into that here. Please name them: Red LED 2, Red LED 3, Green LED 1, Green LED 2, and Green LED3. Once you have completed this, please proceed to the next section of this tutorial where we will bind the SimConnect events to these devices.

Create Output Configurations for your LED devices

You now have six LEDs connected and configured in your Mobiflight module. Mobiflight can connect with the MSFS2020 simulator through SimConnect and the Mobiflight WASM module. Data and commands from the Mobiflight boards can be sent to the simulator and flight data can be received. For this tutorial, we want to receive data from the simulator by reading three variables that contain the landing gear position of the airplane at any time. Output configurations are used to read the variables from the simulator.

Go to the Outputs tab of MF Connector and at the bottom row select the "Add Output Config". Name this configuration "Nose Gear In Transit". Open this configuration by clicking on the three dots at the right side of the row. Now, select the SimConnect (MSFS2020) type. This will give you access to the large number of simulator variables available from the preset menus. From the Group drop down list select "Microsoft/Generic/Gear" and in the Preset drop down list, select "GEAR CENTER POSITION". The correct variable will appear in the Variable field below.

The variable returns a number between 0 and 100 representing the percent extension of the nose (center) landing gear. Zero is completely retracted and 100 is completely extended. We want the nose gear in transit light to be on only when the gear position is between 1 and 99 percent. To achieve this, we enter the following formula in the Transform field:

if($>0 && $<100,1,0)

This formula results in a value of 1 or ON state for the LED if the gear is extended between 1 and 99. If the gear is either fully retracted (0) or fully extended (100) this "Red LED 1" will be OFF. The approach used in the video tutorial is a little different, taking advantage (in the video) that any value higher than 0 causes the LED to turn on. I decided not to use this approach because it works only if you don't use the LED dimming PWM function. In the configuration presented here, the PWM logic can be added later with minimum modifications.

image

Please repeat this same output configuration procedure for the Red LED 2 and Red LED 3. The SimConnect variables to look for are (as you would expect): "GEAR LEFT POSITION" and "GEAR RIGHT POSITION". Use the same Transform formula for all of the red LEDs.

You have now completed the configuration of the gear in transit indicator red LEDs. The next step is to configure the green LEDs. This is very similar to the first set of LEDs. You read the same three variables for Nose, Left and Right gear positions. You can name these configurations "Nose Gear Extended", "Left Gear Extended" and "Right Gear Extended". The only difference is in the Transform formula given below:

if($=100,1,0)

In this case, the fully extended gear indicator LEDs will only turn ON when the gear position is equal to 100. Repeat the same procedure, changing the Transform formula for all three green LEDs.

image

Press OK to close and be sure to save your Mobiflight configuration by pressing the Save button.

CONGRATULATIONS. You have completed the configuration of your Landing Gear indicator lights. Now, please test them in the simulator. Extend and retract your gears and watch how the lights turn on and off in sync with the action of the simulator. Enjoy!