When starting this Baron 58 project we wrote lots of test code for Arduino, to clarify all aspects of data exchange between Arduino and X-Plane, initially using only inbuilt Ethernet UDP protocol of X-Plane, without plugin or any other software and library.
You can take o look at few of these early programs in the "Code Archive", where you will see the evolution of Arduino I/O interface for our Baron project.
For this Baron-58 project Arduino "Mega-1280" board coupled with Ethernet shield was used. To extend the number of inputs we made a DIY extention board for 128 inputs, as well as the board with output registers for LED indicators (serial output from Arduino):
Note: The input extension method described here was designed specifically for our Baron 58 project and should NOT be considered as the only possible or recommended option for your own cockpit project!
You may use our latest SimVimCockpit interface without the need to program Arduino.
Later, since summer 2014 all this work and test sketches were revised and organized in a single Arduino library (XPData, closed project) that included functions for network interaction between Arduino and X-Plane, functions for receiving and decoding any of X-Plane incoming data, and functions for transmitting data to X-Plane. It makes Arduino programming for users as simple as possible - you only need to define the pin number and its function (button, switch, encoder, axis, etc.).
The Arduino program monitors all inputs in each cycle, but if no changes were detected, it does not transmit anything to X-Plane. if the program detects that the position of any of the controls was changed, it immediately sends the specific packet via Ethernet. In general, the whole process of data sending (in the newest B58 code editions) takes 1-5 milliseconds in one cycle.
In the last versions of the Baron code the XPData library is used and data from X-Plane is received via ArdSim plugin (without the need to define data groups for output in the "Data Input/Output" X-Plane menu).Currently our Baron 58 is in a process of migrating to SimVim interface..
All information about Arduino programming is here Arduino cockpit Interface. There you can find descriptions of input and output, the libraries, plugins and code samples.
To extend I/O capability of microcontroller, common "key matrix" technique can be used. But for the Baron-58 project I decided to use a parallel input bus interface, because this is convenient and easy way that I have used in my electronics practice.
Using just 8 Arduino pins as inputs plus 4 as outputs we have 128 inputs (this technique could be used for outputs too).
The diagram below shows how to use 8-bit bus transceivers (x16) and one demultiplexer for inputs extension.The extension board needs to be powered from a separate supply! (not from Arduino). Good choice is to use some old PC Power supply (AT) for +5v bus.
Diagram: using 16 8-bit bus transceivers with multiplexer for inputs extension
Diagram: using 8-bit bus transceivers for input extension
Diagram: 8-bit bus transceivers for input extension
Diagram: using 8-bit bus transceivers and registers with latch for input/output extension