How to interface Arduino with KY023 Joystick

In this tutorial, we are controlling the motion of the joystick to left, right, front, back and to corners (front , left, front right, back left, back right) with the help of arduino. 

              joystick interfacing

Components Required

  • Arduino UNO
  • Mini joystick
  • USB Cable
  • Connecting wires: 5 No.

Component Description

  • Mini Joystick

Mini Joystick is a thumb operated device. It consists of two potentiometers and a push button switch made into a solid package with a thumb dome. This joystick is perfect for controlling motors, servos etc. The potentiometers track the direction of joystick in two dimensions in which it is being pushed. While, the switch sends a low when the knob of the joystick is being pressed. The spring pulls the joystick back to the center position.

joystick pinout

Analog inputs are used here to measure the joystick position. Inorder to control the joystick using the thumb, at first we have to know or understand the direction of X and Y. The figure below gives an idea of the X and Y.

joystick position

                                            Movement of joystick according to X and Y.

XY

DIRECTION

X=0

RIGHT

Y=0

BACK

Y=1023

FRONT

X=1023

LEFT

X=0, Y=0

BACK RIGHT

X=1023,Y=0

BACK LEFT

X=0,Y=1023

FRONT RIGHT

X=1023, Y=1023

LEFT FRONT

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

+                           5V

-                            GND

B/SW/KEY           button to receive digital IO ports

X                          X-axis offset, the use of analog IO port read out

Y                          Y-axis offset the use of analog IO port read out

Connection

Arduino pins read the analog data from X/Y pins and a digital pin is used to read the button.

  X of joystick ------ A0 of arduino

  Y of joystick ----- A1of arduino

  B/ SW/ KEY of joystick ----- 7 of arduino

Program

In the program, according to the X and Y value, the joystick movement is noted.  Also, in the program, the key is checked whether it is pressed or not.

User Review (0)
Related Items