Skip to main content

JoyStick HW-504 Interfacing with Arduino

JoyStick HW-504 Interfacing with Arduino

Hello Guys, I hope you all are doing well. My Name is Vivek Garg and I welcome you all to my Blog Mostly Programing. If you're new here I will suggest you to check out my YouTube channel @mostlyprograming. I post 3 New Videos every week, Let's Code Tuesdays, Innovative Thursdays, and Geeky Saturdays. 
Go! Go! Go! Check it out and if you like the content you can maybe give me a subscription or a comment or a like (YOU DECIDE!).

So, In Today's Tutorial, We are going to see How a PS2 Thumb Joy Stick Works? and How we can use one with an Arduino.

Fig. 1 HW - 504 Thumb JoyStick Module

When we hear the word joystick, the first thing that strikes our mind is Game Controllers (Like the one shown in Fig. 2). Mainly we use them for playing Games but we can do a lot of fun stuff with them in Electronics. For instance Controlling Robo Cars, Controlling Barrier Gates, etc.
Fig. 2 Game Controller

Hardware Overview

The Thumb JoyStick HW-504 shown in Fig. 1 is an analog JoyStick similar to those found in PS2 Controllers. Also, The HW-504 JoyStick is Self Centering that means whenever we move the cup-shaped cap to any direction it brings itself back to the center.

The aim of the Joy Stick is to communicate 2D motion i.e. the motion in the X-Y plane to Arduino. This communication of the motion is done with the help of two independent 10 Kilo Ohm Potentiometers. We have to place one potentiometer for each axis. Both potentiometers are housed as such to provide dual-voltage divider configuration.

Fig. 3 Potentiometers on Joy Stick 

The two potentiometers are the two off white boxes on two sides of the JoyStick module. When you move the joystick you will see the center shafts of the potentiometers move.

Also, the joystick contains a push-button (Shown in Fig. 4) that can be used any ordinary Push Button Switch.
Fig. 4 Push Button on Joy Stick

Working Principle 

As mentioned earlier the sole aim of a joystick is to convert the 2D motion in XY Plane to some electronic information that can be processed using Arduino. And this conversion is made with the help of the dual voltage dividers and the Gimbal Mechanism.
The working of a thumb joystick module is based upon the Gimbal Mechanism.
The internal structure of a JoyStick module can be easily understood from the below-shown Fig. 6.
Fig. 6 Internal Structure of JoyStick 

As can be clearly observed from the above diagram that when we move the cap of the joystick the 2 shafts (Gimbals) allow motion in 2 directions either along X-axis or along Y-axis. Motion along X-axis is Left- Right Motion and motion along Y-axis is Up-down motion. 
One potentiometer is connected to each Joystick shaft and in whatever direction the shaft is moved the potentiometer values are affected and thus the analog Readings are changed. 
Fig. 7 shows the placement of the potentiometers inside the JoyStick, also it describes the pin configuration of the module.

Fig. 7 Pinout of JoyStick Module

Reading Analog Values from the JoyStick Module

This is very easy to understand if you know how a potentiometer works. Fig. 8 clearly shows and describes how the analog values change with the movement of the joystick shafts.

Fig. 9 Graph representing analog value readings of joystick module 

Pin Description 

As shown in Fig. 7 HW-504 has 5 pins. Namely, Gnd, Vcc, VRx, VRy, SW.
Let us see what these 5 pins are for.

Gnd --->  It is the Ground Pin which will be connected to ground pin of Arduino
Vcc ---> It is the power supply pin of the module and it must be connected to +5volts pin of Arduino.
VRx ---> It gives the reading of analog values in the Horizontal direction.
VRy ---> It gives the reading of analog values in the vertical direction.
SW ---> This is the push button switch and it is connected to any digital pin and the digital pin of Arduino reads if the button is pressed or not.

Circuit Diagram 

Fig. 9 shows the interfacing diagram and the connections of the JoyStick module to the Arduino Uno.
Components Required are

  • Breadboard 
  • Arduino Uno
  • HW 504 JoyStick Module\

Fig. 9 Circuit Diagram
Connections

GND---> GND
Vcc  ---> 5volts
VRx ---> A0
VRy ---> A1
SW  ---> D2

Arduino Code


You can download the code from the link below.
https://drive.google.com/open?id=1wu-ODarZZ8Fc9TR5Ldtu8DgBdNL7zvKe

YouTube Video




Also, If you have any queries, feel free to comment down below and I will try my best to solve, or you can directly DM me at my social media accounts.

Twitter    


Content Creator: Vivek Garg

Comments

Popular posts from this blog

Flappy Bird Game with Arduino Uno

Flappy Bird Game with Arduino Uno Hello Guys, I hope you all are doing well. My Name is Vivek Garg and I welcome you all to my Blog Mostly Programing. If you're new here I will suggest you to check out my YouTube channel  @mostlyprograming . I post 3 New Videos every week, Let's Code Tuesdays, Innovative Thursdays, and Geeky Saturdays.  Go! Go! Go! Check it out and if you like the content you can maybe give me a subscription or a comment or a like (YOU DECIDE!). So, Today we are gonna build a fun game with Arduino. This game is called The Flappy Bird game, I bet you must have played this game in your childhood. And if not you can make one today and play. Components Required 1 x BreadBoard 1 x Arduino Uno Board 1 x I2C LCD Display (16x2) 1 x 10 KOhm Resistor 1 x Push Button Jumper Wires USB A/B Cable Circuit Diagram Fig. 1 Circuit Diagram Connections: SCL(LCD) ---> A5/SCL Pin SDA(LCD) ---> A4/ SDA Pin Vcc (LCD) ---> +5Volts Gnd

How to use a Push Button with Arduino

How to use a Push Button with Arduino Hello Guys, I hope you all are doing well. My Name is Vivek Garg and I welcome you all to my Blog Mostly Programing. If you're new here I will suggest you check out my YouTube channel  @mostlyprograming . I post 3 New Videos every week, Let's Code Tuesdays, Innovative Thursdays, and Geeky Saturdays.  Go! Go! Go! Check it out and if you like the content you can maybe give me a subscription or a comment or a like (YOU DECIDE!). In today's tutorial, we are going to see how a push-button works. I know that may sound quite easy to some of you but believe me, it's not as easy as it seems to be (especially for the Newcomers).  So, Today we will be seeing  What is a push-button? How it works? What different configurations can it work in? How to interface one with an Arduino? Also, How to read its status using a software program? How do we control an LED using a Push Button? Let's get started with the Tutorial.