In this tutorial you learn how to use a switch and how to configure it in MobiFlight Connector
At the end you can control the parking brake state with your switch by using a FSUIPC Offset.
In this tutorial you connect a switch to your Arduino Mega board. The switch will be configured in such a way that you control the parking brake of your aircraft in the simulator. Therefore you set the correct value at an FSUIPC offset.
First, you'll see how to electronically connect the switch. Then the configuration of the software is explained step by step.
The tutorial extends the LED Tutorial - if you haven't done it yet this might be a good moment. In the schematic pictures the LED shows up.
The connection of the switch can be done directly at one of the pins of your arduino Mega board.
In this example a switch is connected to "pin 40" and "GND".
After starting MobiFlight Connector you'll see the main window with an overview of your current configurations. In this example nothing is configured so far.
Open the settings dialog, so that you can configure the MobiFlight-Board correctly. It must know at which pin a certain device is connected - in this case our switch.
Click Extras > Settings > MobiFlight Modules-Tab
Choose the desired MobiFlight Board from the tree view at the left.
In the toolbar below the tree view, different actions are available. To add a switch click "New Device" > "Switch".
You can also right-click above the module in the tree view. A context menu comes up which offers the same option (see screenshot)
A switch has been added to your module.
On the right side you can configure device specific options.
For a switch there are only two things
Changes are currently only made in the tree view. The module has not yet received the new configuration. Let's do that now.
Upload the current configuration to you module by clicking the upload-button on the very left of the toolbar.
A message appears if the upload was successful. Now your MobiFlight board knows what to do even if you reset it or power off.
You can now close the settings dialog by clicking OK-Button. You will be back in the main window with the configuration overview - which still is empty.
Your MobiFlight Board knows now that there is a switch connected at pin 40, but you still have to assign an action to it when its pressed or released.
First, you change to the inputs-tab which contains all configurations for inputs. The list currently is empty because we have not configured anything yet.
Let's create a new configuration for the parking brake switch.
First, assign a name to the configuration by double-clicking on the description field. Name it "parking brake".
Click on the "..."-Button at the end of the row. This will open the "Input Config Wizard".
The Input Config Wizard is similar to the Config Wizard used for outputs. We had introduced it in the LED tutorial.
Change to the "Input"-Tab since we don't need any preconditions for our configuration.
Choose your connected module from the "Module"-DropDown-list.
Choose your configured switch from the "Device" drop down list.
Once you have selected your switch, the input setting section will update accordingly and offer assignment options for your switch.
A switch allows to assign different actions for the "On press" (you have pressed or closed it) and "On release" events (you have released or opened it). The parking brake state will be set via a FSUIPC offset.
Hence, at "Input Settings" > "Action type" you choose "FSUIPC Offset".
Select the preset "General - Parking Brake" from the preset list.
Click "use"-Button next to the DropDown-Field to confirm.
Now nearly all settings are automagically set. But, the actual value that shall be set at the FSUIPC offset once you toggle the switch is still missing. The FSUIPC offset value must be "1" if the parking brake is set, "0" if it is released.
Therefore, put the value "1" in the field "Value".
Your settings should now look like the following:
Go to the "OnRelease"-Tab and perform the same steps there.
This time, use 0 in the "Value" field.
Close the "Input Config Wizard"-Dialog by clicking the "OK"-button.
As a last step you have to activate your config row. Click the checkbox at the beginning of the row. Only active configuration rows are later executed.
Start your favourite flight simulator, e.g. Microsoft Flight Simulator X or x-plane.
Load and start your flight.
Wait a moment until the FSUIPC connection becomes established. You can see the status of the connection in the status bar indicated by the green symbol.
Let the MobiFlight Connector run, by clicking the "Start"-Button in the toolbar.
Now toggle your switch and set and release the parking brake with it. Your switch and the parking brake are always in sync. That's cool isn't it?
If you have also done the Tutorial - The 1st LED and your config is still active, then this should do well together. The LED turns on and off accordingly.
You have successfully configured your first switch and you have controled the value of an FSUIPC offset. Go ahead and try out more stuff, like settings lights, fuel pump or your engine starter.
Tell us on the forum about your progress and your project. We are looking forward to your feedback!