Skip to content

MSFS2020 How to Create a Blinking LED configuration

JaimeLeon2 edited this page Jul 18, 2021 · 52 revisions

HOW TO CREATE A BLINKING LED WITH MOBIFLIGHT AND WASM MODULE

In this tutorial, we will keep things simple by just configuring an LED that blinks first, nothing else. This procedure assumes you already have a working installation of Mobiflight, the wasm module and at least one LED connected to your board and configured in Mobiflight Modules.

  1. Create an output config that will use the simulator time variable. Enter this variable name in the Variable field of the output config window. (E: SIMULATOR TIME, second) This variable displays the time in seconds elapsed since the simulator started.

  2. Add some integer math to this variable by applying the modulo function with 2 as divider. (E:SIMULATOR TIME, second) 2 % This simple statement will now display an alternating value of 0 and 1 each second. You can name this config as "Blink 1 second". You could configure a LED to display with this output, but it would not be very useful, as the LED will blink forever. So we next add a variable to control when to blink.

    image

  3. Create an output config for the variable you wish to display with the blinking LED. For example the classic Parking Brake variable used in the old Mobiflight tutuorial: (A:BRAKE PARKING INDICATOR,Bool)

    image

  4. Configure the Display tab to use a LED in your board. This part is identical to the LED for parking brake tutorial. With this You should have a LED that turns on and off with the Parking Brake indicator.

  5. We will now add the blink function by using the Transform field and bring the “Blink 1 second” config as a config reference. Go to Config References and put a checkmark on the first config ref. Select from the list of configs “Blink 1 second”. Now use the placeholder for that config ref, which in this case it is the “#” sign and put the formula $*# in the Transform field. Both variables in this formula only take values of either 0 or 1 so multiplying the two together results also in a value of 0 (if either variable is equal to 0) or 1 (only when both variables are equal to 1).

    image

  6. Save your MF config. Your LED will now blink once per second when the Parking Brake is ON.

ALTERNATE METHOD USING ONLY ONE OUTPUT CONFIGURATION

The same effect can be achieved with only one output configuration by moving all the math to the output configuration Variable field with something like the following statement:

 `(A:BRAKE PARKING INDICATOR,Bool) (E:SIMULATOR TIME, second) 2 % *`

image

VARIATIONS ARE POSSIBLE FOR OTHER USE CASES

This type of technique can be used with some modifications in other instances, like blinking values in an LCD screen.

The frequency of the blink can also be adjusted by changing the formula used in the blink. For example you can increase the frequency to twice per second by multiplying the E: variable times 2.

 `(E:SIMULATION TIME, second) 2 * 2 %`

On the other hand you can have the frequency drop to once every 5 seconds by diving the variable by 5.

 `(E:SIMULATION TIME, second) 5 / 2 %`

Installation

User Interface

Examples and tutorials

MSFS2020

X-Plane

Workshops

Community Boards & Devices

Additional Information

Firmware

Clone this wiki locally