Skip to product information
1 of 7

Keszoox

Joystick Module

Joystick Module

Regular price $1.59 USD
Regular price $2.59 USD Sale price $1.59 USD
Sale Sold out
Taxes included. Shipping calculated at checkout.

2-axis analog outputs based on position of joystick

Description

The Joystick Module provides 2-Axis analog outputs based on the X/Y position of the joystick as well as a pushbutton activation when the joystick is pressed.

PACKAGE INCLUDES:

  • Joystick Module w/ snap-on cap

KEY FEATURES OF JOYSTICK MODULE:

  • 2-Axis analog outputs based on the X and Y position of the joystick
  • Pushbutton action when joystick is depressed
  • 3.3 and 5V compatible

The joystick module is a fully functional joystick similar to what is found on many game controllers and can be used for a number of different control applications such as for controlling a robotic system.

An acrylic base is also available at the bottom of the page.

Joystick Controls

The module includes two spring loaded 5K potentiometers that provide X and Y analog outputs which can be input to two analog inputs on an MCU.  There is also a push button switch output if the cap is pressed down until an audible click is heard.  The pushbutton output can be connected to any digital input pin of an MCU.

For reference, the X-Axis is motion parallel to the header pins on the module while the Y-Axis is motion perpendicular to the header pins.

The analog inputs on an MCU read values over a range of 0-1023 (for typical 10-bit ADC inputs).  The X-Axis and Y-Axis controls should read around 512 (midpoint) when the control is at rest.  As the joystick is moved, one or both of the controls will register higher or lower values depending on how the control is being moved.  When the joystick is released, it is spring-loaded and will return to center.

The switch output is grounded (LOW) when the switch is pushed.  When the switch is at rest, the output is floating, so a pull-up resistor is needed to pull the output high.  When using with an MCU, the input pin that the switch is connected to should have the built-in pull-up enabled or else an external pull-up resistor can be used.

Module Connections

There is a 5-pin header on the assembly for making connections.

1 x 5 Header 

  • GND  = Ground
  • +5V = Vcc (3.3 – 5V)
  • VRx = Analog X-Axis output.  Connects to analog input on MCU
  • VRy = Analog Y-Axis output.  Connects to analog input on MCU
  • SW = Switch Output, active LOW.  Connects to digital input on MCU

Joystick Module Test Program

/*
Joystick Module Test

Basic code for monitoring the outputs of the module. 
*/
int xPin = A1;      // Use any analog input pin to read X-Axis pot
int yPin = A0;      // Use any analog input pin to read Y-Axis pot
int buttonPin = 2;  // Use any digital input pin to monitor button

int xPosition = 0;  // Variable to hold current X-Axis reading
int yPosition = 0;  // Variable to hold current Y-Axis reading
int buttonState = 0;// Variable to hold current button state
//===============================================================================
//  Initialization
//===============================================================================
void setup() 
{ 
  Serial.begin(9600); 
  
  pinMode(xPin, INPUT);
  pinMode(yPin, INPUT);
  pinMode(buttonPin, INPUT_PULLUP);   // Enables pull-up resistor on button pin
}

//===============================================================================
//  Main
//===============================================================================
void loop() 
{
  xPosition = analogRead(xPin);         // Read the current state of all 3 controls
  yPosition = analogRead(yPin);
  buttonState = digitalRead(buttonPin);
  
  Serial.print("X: ");                  // Print current state out to Serial Monitor window
  Serial.print(xPosition);
  Serial.print(" | Y: ");
  Serial.print(yPosition);
  Serial.print(" | Button: ");
  Serial.println(buttonState);

  delay(250);    // add some delay between reads.  Using long delay to make easier to read
                 // output on screen.  This delay would be shorter to improve responsiveness in
                 // live application.
}

BEFORE THEY ARE SHIPPED, THESE MODULES ARE:

  • Sample inspected and tested per incoming shipment

Notes: 

  1. This is similar to or the same as the KY-023 module.

Technical Specifications

Operating Ratings  Vcc Range 3.3 – 5V
 Analog Outputs 0 – Vcc
Pushbutton Output Active Low
 Dimensions L x W (PCB) 40 x 22mm  (1.6 x 0.9″)

View full details