-
-
Notifications
You must be signed in to change notification settings - Fork 147
MSFS2020 Transponder Keypad and Display on 7 Segment Module
In this tutorial we will configure Mobiflight to mimic the operation of the ATC (Transponder) panel keypad of the FlyByWire A320 mod airplane. Our focus will be only on mimicking the behavior of the keypad and display, using RPN code in both input and output configurations. We will not cover the other knobs and buttons in the ATC panel.
The keypad has 9 keys, 8 numeric (numbers 0 to 7) plus a CLR key. The display shows the four octal digits transponder code. In normal operation, the numeric keys are disabled and the CLR key is pressed once or twice, depending on the action needed. Press CLR once to delete and reenter the last number, or press twice to delete the four digits and reenter the entire code. The led display will show the transponder code in normal operation or each new digit from left to right, when entering a new transponder code. The CLR key can be pressed at any time during entering a new code to delete the last number entered, or press twice to restart the code entry. If there is a delay of 7 seconds or more at any time during the entry of the code prior to completing the four digits, the unit resets the display back to the previously used code. This is the behavior we intend to reproduce in our external ATC panel keypad and display.

We will need to have a
- Any supported Arduino board (Mega, Pro Micro, Uno, Nano)
- One MAX7219 eight digit 7-Segment LED display module (we will only use four digits),
- Nine buttons for the keypad
- Working installation of MSFS2020 and Mobiflight
We assume that you know how to wire the 7-segment display module and buttons to your Arduino board. If not, please pause this tutorial and refer to more basic tutorials already available on how to wire and configure devices with Arduino and Mobiflight. Please take note of the pin numbers used by the LED module display and the nine buttons. Once the hardware is wired to the arduino, please create the corresponding devices in your Mobiflight board configuration. Again, we assume that adding device configurations to your Mobiflight board is known by you. Be sure to upload the board configuration once you have completed the device configurations. Also save this configuration to a mfmc file.
Next, you need to create nine input configurations for the nine buttons and one output configuration for the LED display module.
Let's start with the button for "1". Name this configuration "ATC Btn 1". In the input tab select the board and corresponding button, which you have already created. In the On Press tab, select "MSFS2020-Custom Input" and enter the following code:
KEY 1
(L:XPNDR_clr) 0 > if{ 1 (>L:XPNDR_key) 1 (>L:XPNDR_act,bool) (>H:A320_Neo_ATC_BTN_1) }

Notes on the code:
XPNDR_clr is a user-defined control variable used to flag when the CLR key has been pressed. The CLR key should be pressed in order to activate entering numbers on the keypad, therefore we first check if this variable is not zero. If false, we do nothing. If true, we enter a "1" in variable XPNDR_key. This variable holds the value of the last key pressed to be used later. We then set the XPNDR_act variable to 1, signalling that a keypad key has been pressed. To maintain the sim in sync with our key press, we call the A320 H: event for the same key press.
All 8 keys from 0 to 7 will be treated in the same way. The only difference in the code for each key press will be the value entered in XPNDR_key and the corresponding H: event to maintain the sim display in sync with ours.
Following is the list of code to be entered in the Custom Input box for each subsequent button configuration. Please proceed to create the additional button configuration in the same way as the configuration for the "1" Key.
KEY 2 (L:XPNDR_clr) 0 > if{ 2 (>L:XPNDR_key) 1 (>L:XPNDR_act,bool) (>H:A320_Neo_ATC_BTN_2) }
KEY 3 (L:XPNDR_clr) 0 > if{ 3 (>L:XPNDR_key) 1 (>L:XPNDR_act,bool) (>H:A320_Neo_ATC_BTN_3) }
KEY 4 (L:XPNDR_clr) 0 > if{ 4 (>L:XPNDR_key) 1 (>L:XPNDR_act,bool) (>H:A320_Neo_ATC_BTN_4) }
KEY 5 (L:XPNDR_clr) 0 > if{ 5 (>L:XPNDR_key) 1 (>L:XPNDR_act,bool) (>H:A320_Neo_ATC_BTN_5) }
KEY 6 (L:XPNDR_clr) 0 > if{ 6 (>L:XPNDR_key) 1 (>L:XPNDR_act,bool) (>H:A320_Neo_ATC_BTN_6) }
KEY 7 (L:XPNDR_clr) 0 > if{ 7 (>L:XPNDR_key) 1 (>L:XPNDR_act,bool) (>H:A320_Neo_ATC_BTN_7) }
KEY 0 (L:XPNDR_clr) 0 > if{ 0 (>L:XPNDR_key) 1 (>L:XPNDR_act,bool) (>H:A320_Neo_ATC_BTN_0) }
The CLR Key is very important in this setup. Remember, the keypad remains inactive until the CLR is pressed. The first press of the CLR key is to delete and reenter the last key pressed. To enter a new transponder code, the CLR key needs to be pressed twice. This requires some special treatment in the code in order to detect this second key press.
Create the button configuration in the same way we did for the number buttons. The code for the CLR key is a bit more complicated
KEY CLR
(L:XPNDR_clr) s1 2 < if{ (L:XPNDR_pos) -- s0 0 < if{ 3 } els{ l0 } (>L:XPNDR_pos)
l1 0 == if{ (A:TRANSPONDER CODE:1,number) } els{ (L:XPNDR_temp) } 10 div (>L:XPNDR_temp) 2 (>L:XPNDR_clr) }
els{ 0 (>L:XPNDR_temp) 0 (>L:XPNDR_pos) }
(>H:A320_Neo_ATC_BTN_CLR)
(E:SIMULATION TIME,second) 7 + (>L:XPNDR_timeout)

Notes on the CLR key code:
The first thing we need to check is to see if this is the first or second press of this key. XPNDR_clr is zero when there is no action pending. Therefore if the value of XPNDR_clear is equal to 0 or 1, we have the first press. To backspace one digit in the code we take either the current Transponder code (if no partial code has been entered yet) or the partial code being entered in XPNDR_temp and do integer division by 10. In effect, this shifts the code one position to the right. In the first press, the variable XPNDR_pos is decreased by one (to edit the last entered number) and XPNDR_clr is set to 2.
If the CLR key is pressed again, it will have a value of 2 and the code will set for entering the entire Transponder code. To that effect, the variables XPNDR_temp and XPNDR_pos are both set to 0
We now call the H: event for the CLR key to maintain the in sim display in sync.
Lastly, we take care of the key timeout. The simulator has this variable "SIMULATION TIME" which keeps count of the time elapsed since the sim started to run. The timeout works by reading this variable (now time), adding 7 seconds and storing this in XPNDR_timeout. This adding of 7 seconds is done each time any key is pressed. We will see later how the timeout check code uses this information.
OUTPUT CONFIG 1 - NUM KEY PRESS HANDLER - 7 SEGMENT DISPLAYS THE CODE WHILE EDITING (SPACE NO PAD)
(L:XPNDR_act,bool) if{ 0 (>L:XPNDR_act) (L:XPNDR_clr) 2 == if{ 1 (>L:XPNDR_clr) } (L:XPNDR_key) (L:XPNDR_temp,number) 10 * + (>L:XPNDR_temp,number) (L:XPNDR_pos) ++ 4 min s0 (>L:XPNDR_pos) l0 4 == if{ (L:XPNDR_temp,bco16) (>K:XPNDR_SET) 0 (>L:XPNDR_timeout) 0 (>L:XPNDR_temp,number) 0 (>L:XPNDR_pos) 0 (>L:XPNDR_clr) } (E:SIMULATION TIME,second) 7 + (>L:XPNDR_timeout) } (L:XPNDR_clr) 0 > if{ (L:XPNDR_temp) } els{ (A:TRANSPONDER CODE:1,enum) }
OUTPUT CONFIG 2 - 7 SEGMENT DISPLAYS THE TRANSPONDER CODE (ZERO LEFT PAD)
OUTPUT CONFIG 2 - 7 SEC TIMEOUT HANDLER
(L:XPNDR_timeout) 0 != if{ (E:SIMULATION TIME,second) (L:XPNDR_timeout) > if{ 0 s0 (>L:XPNDR_timeout) l0 (>L:XPNDR_temp) l0 (>L:XPNDR_pos) l0 (>L:XPNDR_clr) } }
- MobiFlight Connector Installation
- Mobiflight Connector BETA version installation
- Modules
- MobiFlight Connector Files Structure
- MobiFlight Connector Uninstall
- Modules Reset to factory default
- Verifying the WASM module installation and locating the MSFS2020 community folder
- Verifying the WASM module installation and locating the MSFS2024 community folder
- Using a Winwing FCU with MobiFlight
- Using VKB controllers with MobiFlight
- Providing logs from MobiFlight
- MobiFlight Connector How does it work
- Mobiflight Connector Main Window
- Flash module with MobiFlight firmware
- Input and Output devices
- Joysticks
- Midi Boards
- Sim Variables (for Output)
- Input Actions
- Merging configuration files
- Disabling specific COM ports
- Examples Output LEDs
- Examples Input Switch
- Example 7 segment display
- Example Servo motor
- Controlling LEDs with an output shift register
- Adding lots of buttons with an input shift register
- Beginner's guide to input multiplexers
- Key Matrix with standard MobiFlight and Multiplexers
- Tutorial Easy Driver and x.27 or x.40 Stepper Motor
- Tutorial for Airbus VS display via 7-Segment LED Module
- Example Analog Input Potentiometer
- Baron G58 Tutorial Gear, Flaps, Mags, ELT Input Output Programming
- Using Mobiflight to control arduino-based 3rd party panels (RealSimGear GNS530)
- How to use a VNH2SP30 DC motor shield with MobiFlight
- Using 3D printer mainboards
- Playing sounds by sending keystrokes to AutoHotKey
- Using the selector knob on a Honeycomb Bravo
- Using an adjustable 12 position switch as a GA starter
- Brightness of LCD displays with I2C
- Using three-position switches
- Transponder with one Rotary
- Workflow for Creating Flight Simulation Panels ‐ Part 1
- MSFS2020 RPN Tips and Tricks
- MSFS2020 Using the Custom Input Code Box
- MSFS2020 Install WASM module and Event List
- MSFS2020 How to Create and Use User Defined Lvars
- MSFS2020 How to Create a Blinking LED configuration
- MSFS2020 User Defined WASM Module Events Best Practices
- MSFS2020 Developer Mode, Model Behavior dialog and Console window
- MSFS2020 PMDG 737‐700 List of Events that require use of FSUIPC7
-
MSFS2020 PMDG 737‐700 Calibrate throttle idle and reverse thrust using interpolation (Valkyrie)
- MSFS2020 PMDG 737-700 Chrono unit functions implemented in Mobiflight
- Configuring PMDG 737 Parking Brake Lever Auto-Release with a Servo in Mobiflight
- Using encoder to drive a value back and forth within a given range
- Adding a custom board to MobiFlight
- User guide - Community Board and Custom Devices
- Developing your own custom devices/boards