Handson Technology
Data Specs
PS2 Joy Stick for Arduino/Raspberry
This PS2 style joystick is a thumb operated device, offers a convenient way of getting user
input. It is fundamentally consists of two potentiometers and a push button switch. The two
potentiometers indicate which direction the potentiometer is being moved. The switch sends
low (or ground) when the joy stick knob is pressed. 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.
SKU: ASS-1056
Brief Data:
Analog output: 2-Axis X and Y.
Digital Output: One Push Button.
Interface: 5-pins.
Mounting: 4x M4 mounting hole.
Dimensions: (34 x 26 x 32) mm.
1 www.handsontec.com
Pin Assignment:
This input device interfaces to your Arduino via five pins. Three of which are inputs to your Arduino,
while the remaining two supply voltage and ground.
PS2 Joy Stick Schematic:
Output Orientation:
In order to put this thumb controller to use, you need to understand which direction is X and which direction
is Y. You will also need to decipher the direction it is being pushed in either the X or the Y direction. In this
tutorial we are using analog inputs to measure the joystick position. The analog inputs provided indications
that range between 0 and 1023. The graphic below shows the X and Y directions and also gives an
indication of how the outputs will respond when the joystick is pushed in various directions.
2 www.handsontec.com
Arduino PS2 Joystick Tutorial:
Setup the PS2 Joystick to Arduino Uno controller board as below diagram. Note that the use of pull up 1KΩ
resistor between the key switch and the digital input. Once you move beyond experimentation, recommend
some sort of software or hardware debounce for this switch as well.
Upload the following sketch to Arduino Uno board:
/*==========================================================================
// Author : Handson Technology
// Project : Arduino Uno with PS2 Joystick
// Description : Reading PS2 Joystick Value with Arduino Uno
// Source-Code : ps2-Joystick.ino
// PS2 Jostick Module: KY023
//==========================================================================
*/
int Xin= A0; // X Input Pin
int Yin = A1; // Y Input Pin
int KEYin = 3; // Push Button
void setup ()
{
pinMode (KEYin, INPUT);
3 www.handsontec.com
Serial.begin (9600);
}
void loop ()
{
int xVal, yVal, buttonVal;
xVal = analogRead (Xin);
yVal = analogRead (Yin);
buttonVal = digitalRead (KEYin);
Serial.print("X = ");
Serial.println (xVal, DEC);
Serial.print ("Y = ");
Serial.println (yVal, DEC);
Serial.print("Button is ");
if (buttonVal == HIGH){
Serial.println ("not pressed");
}
else{
Serial.println ("PRESSED");
}
delay (500);
}
Open up the Serial Monitor with baud rate of 9600, move the PS2 joystick and observe the reading:
4 www.handsontec.com
Handsontec. com
HandsOn Technology provides a multimedia and interactive platform for
everyone interested in electronics. From beginner to diehard, from student
to lecturer. Information, education, inspiration and entertainment. Analog
and digital, practical and theoretical; software and hardware.
HandsOn Technology support Open Source Hardware (OSHW)
Development Platform.
Learn : Design : Share
www.handsontec.com
5 www.handsontec.com
The Face behind our product quality…
In a world of constant change and continuous technological development, a new or replacement
product is never far away – and they all need to be tested.
Many vendors simply import and sell wihtout checks and this cannot be the ultimate interests of
anyone, particularly the customer. Every part sell on Handsotec is fully tested. So when buying from
Handsontec products range, you can be confident you’re getting outstanding quality and value.
We keep adding the new parts so that you can get rolling on your next project.
Breakout Boards & Modules Connectors Electro-Mechanical Parts
P
Engineering Material Mechanical Hardware Electronics Components
Power Supply Arduino Board & Shield Tools & Accessory
6 www.handsontec.com