Contents

Joystick



Data

DataTypeValues
Horizontal position Xsigned char-100..100 position of joystick on x-axes
Vertical position Ysigned char-100..100 position of joystick on y-axes

The joystick is a proportional control item and allows to transmits to the microcontroller smooth change its position on two axes: x and y. Joystick controlled by moving finger within the its area and allows to smoothly change the value from -100 to 100 (integer) for each of the axes. The joystick can be addition the centering button or switch of using the accelerometer (G-sensor). Properties of joystick allow to specify the different values:

  • Variable name - name of the joystic and the variable in the source code for the microcontroller, allow to set a name for the variable of C rules.
  • Centering - installation of additional control of joystick, allowing move the joystick in the center. Additional control can be set to one of four locations on each side of the joystick. Setting this control affects the behavior of the joystick. If this control is not installed, when you release finger from the joystick, its automatically set in the middle. If this control is installed, then when you release finger from the joystick his slider remains in the same position.
  • Enable G sensor - installation of additional control of joystick to manipulate a its by tilting the smartphone/tablet (with the appropriate sensor). Additional control can be set to one of four locations on each side of the joystick. This control can be turned on and off the G-sensor.

Code example

Example of controlling two servos via the joystick. Since the servos have different characteristics, the calibration values are required for each. Variables SERVO_X_Center and SERVO_Y_Center determine the position of the center point. Center values should be predefined in the code and can set values in the range of 1000 to 2000 ms.

int SERVO_X_Center = 1500; int SERVO_Y_Center = 1500; servo_x.writeMicroseconds(RemoteXY.joystick_1_x*10 + SERVO_X_Center); servo_y.writeMicroseconds(RemoteXY.joystick_1_y*10 + SERVO_Y_Center);