How to Use a PS2 Game Joystick Module with Arduino

If you love gaming or working with Arduino projects, a PS2 Game Joystick Module (KY-023) is a must-have component. This analog joystick works just like the one in PlayStation controllers. It can be used to control robotic arms, drones, motorized systems, and even gaming applications.

In this tutorial, we will learn:
โœ… How the PS2 joystick module works
โœ… How to connect it with an Arduino Uno
โœ… How to read joystick movement (X & Y axes) and button press
โœ… How to display output in the Serial Monitor


What is a PS2 Game Joystick Module?

A PS2 Game Joystick Module is a simple 2-axis analog input device with a built-in push button.

๐Ÿ”น X-Axis (VRX) โ€“ Left & right movement
๐Ÿ”น Y-Axis (VRY) โ€“ Up & down movement
๐Ÿ”น Button (SW) โ€“ Activated when the joystick is pressed down

It works like two potentiometers to detect movements, giving values between 0 and 1023.


Components Required ๐Ÿ› 

Component Quantity
Arduino Uno 1
PS2 Joystick Module 1
Jumper Wires 5

Wiring the PS2 Joystick with Arduino

Below is the wiring diagram for connecting the KY-023 joystick module to an Arduino Uno.

Joystick Module Pin Arduino Uno Pin
VRX (X-axis) A0
VRY (Y-axis) A1
SW (Button) D2
VCC 5V
GND GND

Schematic Diagram

Hereโ€™s a schematic diagram to visually understand the connections:


Arduino Code for PS2 Joystick

Now, letโ€™s write the Arduino code to read X and Y axis values and detect the button press.

Here Is My GitHub Link

https://github.com/ElectroIoT/37-in-1-Sensors-Kit-Code-And-Libraries/tree/main/1.PS2_Game_Joystick_Module.

All Code
https://github.com/ElectroIoT/37-in-1-Sensors-Kit-Code-And-Libraries

How It Works

1๏ธโƒฃ Detecting X and Y Axis Movement

  • The joystick works like two potentiometers, with values ranging from 0 to 1023.
  • Centered Position: Around 512 (when the joystick is not moved).
  • Left (X decreases), Right (X increases), Up (Y decreases), Down (Y increases).

2๏ธโƒฃ Detecting Button Press

  • The SW pin detects when the joystick is pressed down.
  • LOW = Button Pressed
  • HIGH = Button Not Pressed

Testing the Joystick Module ๐ŸŽฎ

1๏ธโƒฃ Connect the joystick module to the Arduino Uno as shown in the wiring diagram.
2๏ธโƒฃ Upload the code to your Arduino using the Arduino IDE.
3๏ธโƒฃ Open the Serial Monitor (9600 baud).
4๏ธโƒฃ Move the joystick and observe how the X and Y values change.
5๏ธโƒฃ Press the joystick button, and you should see “Pressed” in the Serial Monitor.


Applications of the PS2 Joystick Module

โœ… Game Controllers โ€“ Build custom Arduino-based gamepads.
โœ… Robotics & Drones โ€“ Control robotic arms, RC cars, and UAVs.
โœ… Assistive Technology โ€“ Helps disabled individuals control devices easily.
โœ… CNC & 3D Printers โ€“ Used for manual positioning and machine control.
โœ… DIY Projects โ€“ Use it in home automation, motors, and interactive displays.


Conclusion

In this tutorial, we learned how to interface a PS2 Game Joystick Module with Arduino Uno. We covered:

โœ… How the joystick works
โœ… Circuit connections
โœ… Arduino code to read movement & button press
โœ… Testing & practical applications

Now, you can integrate this joystick into game controllers, robotic projects, and automation systems! ๐Ÿš€


๐Ÿ”— Connect with Me

๐ŸŒ Website
โœ‰๏ธ Email
๐Ÿ“บ YouTube
๐Ÿ”ฌ Hackster.io
๐Ÿ“– Instructables


๐Ÿ“ข Share this article if you found it useful! Happy coding! ๐ŸŽฎ๐Ÿš€

 

 

Share This Post:

Leave a Comment