0% found this document useful (0 votes)
384 views

Joystick Module

This document describes a joystick module that produces analog output voltages between 0-5V depending on the position of the joystick in the X and Y axes. It has 5 pins - GND, +5V, VRx, VRy, and SW. The VRx and VRy pins output voltages proportional to the X and Y position that can be read by a microcontroller. The SW pin is a switch. A sample Arduino sketch is provided to read the X, Y values and switch state and display them in the serial monitor. Instructions for connecting the module and testing it are also included.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
384 views

Joystick Module

This document describes a joystick module that produces analog output voltages between 0-5V depending on the position of the joystick in the X and Y axes. It has 5 pins - GND, +5V, VRx, VRy, and SW. The VRx and VRy pins output voltages proportional to the X and Y position that can be read by a microcontroller. The SW pin is a switch. A sample Arduino sketch is provided to read the X, Y values and switch state and display them in the serial monitor. Instructions for connecting the module and testing it are also included.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 7

JOYSTICK MODULE

Description

Lots of robotic projects need a joystick. This module offers an affordable solution
to that. The Joystick module is similar to analog joysticks found in gamepads. It is made
by mounting two potentiometers at a 90 degrees angle. The potentiometers are
connected to a short stick centered by springs.

This module produces an output of around 2.5V from X and Y when it is in


resting position. Moving the joystick will cause the output to vary from 0v to 5V
depending on its direction. If you connect this module to a microcontroller, you can
expect to read a value of around 512 in its resting position (expect small variations due
to tiny imprecisions of the springs and mechanism) When you move the joystick you
should see the values change from 0 to 1023 depending on its position.

Specifications

Directional movements are simply two potentiometers - one for each axis

Compatible with Arduino interface

The biaxial XY Joystick Module KY-023 applies ARDUINO

Dimensions: 1.57 in x 1.02 in x 1.26 in (4.0 cm x 2.6 cm x 3.2 cm)

5 Pin

Color: Black

Pin Configuration

1. GND: ground
2. +5V: 5V DC
3. VRx: voltage proportional to x position
4. VRy: voltage proportional to y position
5. SW: switch pushbutton

Schematic Diagram

Wiring Diagram

123 4 5

Sample Sketch
const int SW_pin = 2; // digital pin connected to SW
const int X_pin = 0; // analog pin connected to VRx
const int Y_pin = 1; // analog pin connected to VRy
void setup() {
pinMode(SW_pin, INPUT);
digitalWrite(SW_pin, HIGH);
Serial.begin(9600);
}
void loop() {
Serial.print("X: ");
Serial.print(analogRead(X_pin));
Serial.print(" Y: ");
Serial.print(analogRead(Y_pin));
Serial.print(" Z: ");
Serial.println(digitalRead(SW_pin));
delay(250);
}

How to test

The components to be used are:


Microcontroller (any compatible arduino)
Joystick module
1 Pin M-M connectors
Breadboard
USB cable
1. Connect the components based on the figure shown in the wiring diagram using
a M-M pin connector. +5V pin is connected to the 5V power supply, GND pin is
connected to the GND, the VRx and VRy pins are connected to the analog input
pins and the SW pin is connected to the digital I/O pin. Pin number will be based
on the actual program code.
2. After hardware connection, insert the sample sketch into the Arduino IDE.
3. Using a USB cable, connect the ports from the microcontroller to the computer.
4. Upload the program.
5. See the results in the serial monitor.

Testing results

The serial monitor displays the X, Y and Z positions based on the position
of the stick.

When the middle button was pressed:

When the stick was moved downward:

When the stick was moved upward:

When the stick was moved to the left:

When the stick was moved to the right:

You might also like