top of page
Writer's pictureShubham Ubale

Analog Joystick Guide with Pinout & Arduino Interfacing

Updated: Mar 6


Introduction


  • Joystick is an input device. Analog joystick is sometimes called as Control Stick. It is used to control the pointer movement in 2-dimension axis.

  • The joystick has two potentiometers to read user’s input. One potentiometer is used to get the analog output voltage for X-Direction movement and the other potentiometer is used to get the analog output voltage for Y-Direction movement.

  • The potentiometers are connected between +VCC and Ground. They simply behave as Voltage Divider Network.

  • The joystick has one freewheeling Holder. According to the holder movement, the potentiometer knob changes its position and resistance of the potentiometer.





Output Voltage Mapping with XY Position


At Idle position output voltage, will be VCC/2. Now considering VCC = 5 volts, following fig. shows the voltage mapping with different XY position.




When the joystick is at idle position, the output value of the X terminal and Y terminal are Centre (2.5V) of the specified range (0V to 5V). According to the movement of a holder, the output values are varying from minimum limit (0V) to maximum limit (5V).


This Joystick also has a select button/switch that is actuated when the Joystick knob pressed down.

 

Pin Description



Pin 1, 5 - VCC and GND


Supply voltage(+5V) and ground given to Joystick.


Pin 2 –X-OUT


This pin provides an analog output voltage from 0 volts to VCC according to the movement of Holder in X-direction (axis).


Pin 3 - Y-OUT


This pin provides an analog output voltage from 0 volts to VCC according to the movement of Holder in Y- direction (axis).


Pin 4 - Switch


This pin has one tactile switch.


When a switch is not pressed, this pin is connected to VCC through a resistor.


When a switch is pressed, this pin is connected to Ground.

 

Specification of Analog Joystick

  • Operating Voltage: 3V to 5V DC.

  • Output Type: The output in the form of analog voltage

  • Potentiometer: It has an internal 10k Ohm potentiometer used in the joystick to measure the position.

  • Operating temperature: It operates on the 0 to 70 °C temperature range.

 

Alternate options for Analog Joystick

Trackball, Gamepads, etc

 

Analog Joystick interfacing with Arduino


Analog Joystick interfacing with Arduino


Analog Joystick Code for Arduino Uno

const int joystick_x_pin = A2;     
const int joystick_y_pin = A1;

voidsetup(){
 Serial.begin(9600);   /* Define baud rate for serial communication */
}

voidloop(){
  int x_adc_val, y_adc_val; 
  float x_volt, y_volt;
  x_adc_val = analogRead(joystick_x_pin); 
  y_adc_val = analogRead(joystick_y_pin);
  x_volt = ( ( x_adc_val * 5.0 ) / 1023 );  /*Convert digital value to voltage */
  y_volt = ( ( y_adc_val * 5.0 ) / 1023 );  /*Convert digital value to voltage */
 Serial.print("X_Voltage = ");
 Serial.print(x_volt);
  Serial.print("\t");
 Serial.print("Y_Voltage = ");
 Serial.println(y_volt);
  delay(100);
}

This code reads the analog values from a joystick's X and Y pins, converts them into corresponding voltage values, and prints them on the serial monitor repeatedly with a delay of 100 milliseconds in between.


The output on the serial monitor will show two columns of values separated by a tab. The first column will display the X voltage values, and the second column will display the Y voltage values. The values will be updated and printed continuously in real-time as the joystick is moved.



Examples of Analog Joystick interfacing



3 views0 comments

Comments


bottom of page