Blog / News ArdSimX Articles/Guides Project Archive SimVim Panel Baron-58 sim

Using Arduino Analog inputs

Using the ArdSim Interface you can configure Arduino analog pins in several ways:

  • input for use with analogue sensors, such as potentiometer, photoresistor or Hall effect sensor;
  • input for multi-position (rotary) switch composed of several fixed resistors;
  • as a simple digital input for toggle switch or button (supported in the ArdSimX );
  • as digital output to control LEDs, relays etc. (supported in the ArdSimX ) ;

Analog input sensor

A common way to make an analog sensor is using a variable resistor as a voltage divider circuit. Connect the middle pin of a potentiometer directly to input, and the two others - to +5v pin and GND.

For use with Arduino you can take any potentiometer from 1k to 100k, as optimal we recommend 10-20k. (up to 100k the noise is still not a concern - no visible fluctuation for one ADC step within 0-1023 scale).


You can use analog input (with potentiometer, photo sensor or Hall-effect sensor) to control most of the simulator analog variables, including the 3 main axes - pitch, roll, yaw (these 3 axes may require most accurate sensors), throttle and other engine controls, flaps, brakes, instruments lighting etc..

Also you can use a potentiometer as a rotary knob for pointer gauges instead of encoder usage.

For such instruments as Radio Altimeter or others that have a pointer with limited rotation angle (less than 360°), any common potentiometer can be used and you can properly emulate a real knob, when the arrow is rotating corresponding to the rotating knob. (i.e. full stroke of the potentiometer is corresponding to a full circle of the gauge needle).

The instruments with continuous needle rotation, such as VOR, ADF etc. could be controlled with potentiometer as well. But potentiometers mostly have limited rotation angle, so you should rotate the knob in both directions to control the needle. It would be nice to find pot with 360° continuous rotation.

Video - Analog axis Demo

Video #3 below shows potentiometer used as knob for HSI OBS control.


As an option, using a potentiometer as a sensor with mechanical detents (for example, you can use some rotary switch mechanism attached to the potentiometer shaft) you can make a multi-position switch to control one dataref value by setting the precision number equal to the positions number.

Multi-position switch

To control several parameters (commands or dataref values) and save numbers of digital pins you can use one analog pin as input for multi-position switch or a button switch bank.

The diagram shows how to connect a rotary switch to Arduino analog input for use with ArdSim librariy. In this example you have a rotary switch with 5 fixed positions connected to one analog pin. The 5-position switch can be used for typical magneto/starter switch.

You need to get a suitable rotary or linear switch and a number of resistors. ArdSim program reads changes in position and sends commands to X-Plane according to the position and input configuration.

b58img b58img

For an N-position rotary switch you will need N-1 resistors 1...10k each, plus one 100ohm resistor and one 1-5 mcF capacitor. The sum of all resistor values can be between 5 and 30..50 kOhm. For example for 8-position switch you should use seven resistors having the same value (1...5k).

Also, instead of several resistors you can try to use one potentiometer with mechanical detents (rotary switch mechanism attached to the potentiometer shaft).

These two videos demonstrate how the Rotary Switches for Magnetos and Transponder work:


Note: Arduino AVR microcontrollers have several analogue inputs that actually are multiplexed and only one input is connected at once to a single ADC.
It is preferable to connect unused analog pins that are located between the used ones (configured for input) to the ground (due to multiplexed channels fluctuations).

If you have analog input that has been configured for input but doesn't have yet an potentiometer connected to it, pull it down to GND. (Otherwise it will take exsessive processor time and will constantly send wrong data caused by interference to the simulator)

Button array:

Similar to how we use analog input for rotary switch emulation, we can use it for multiple buttons (but not for toggle switches!). If only one button in the group would be pressed in any moment, this method is quite acceptable under this condition.

For the 10-buttons array you will need 12 resistors: 10x 200-300 Ohm, 1x 80-100 kOhm, 1x 50-100 Ohm.

Diagram: how to use Arduino analog inputs as multiple-button inputs

Analog inputs reading, photoresistors used as sensor

If you want to use analog input as an axis (pitch, roll and yaw) we need accurate sensors. In general, common potentiometers are used for this, and I use them for throttles, mixture, prop, rudder.

For the 3 main axes, though, I've often used the LEDs/Photoresistors (tried this long ago, since the first PC simulators), in case of Arduino it is a pair of photoresistors connected as a potentiometer.
Each of them is lighted by LED. When LEDs are moving with the yoke, resistance of one photoresistor is increasing, while the other is decreasing.
In Baron simulator I've implemented the following schematic:

parking brakes (or Cessna-like throttle if used without detents) on analog inputs ( options )

© Copyright 2012 - Vlad Sychev