Hi! welcome to Robojax. in this video I'm going to show you how we can use this dual access XY
joystick for Arduino this can be used as a for game controller and for robotics arm or
any other application that you wish so what we do is that we will be able to detect the
switch when you push it the flight is on we will detect the switch and also if you pay
attention on the screen here so now x and y position if I go to the right it shows Y has
moved go to the left y is 0 and then X and then X forward or somewhere in between so you can do
any movement that you want and you see the value is reflected so this video would be just to get
the value but also next and the next video I will have a actual screen to move a dot on the
screen but for now for simplicity this is general introduction for this so let's get started so you
can get the code by clicking at the link at the description which will take you to Robo
Jackson flash learn search or do we know so you can get the code by clicking at the link at the
description which will take you to Robo Jack's that consolation learn search or do we know
so this is joystick XY dual access module is one of the interesting and easy to use module this can
be removed and then let me just explain the pin first so we have so we have the these pins here
so this will be connected to the ground and then we were connecting it to five volt this one and
then these two are variable X which is connected for X and then variable for Y and then we have a
switch so this will go to switch to switch so inside this we have a variable resistor
something like this okay so this has a housing you can it's covered all but it have a handle
so we have exact same thing here and the handle is inside so as if as if we have this here okay
so the handle is there when you move this left and right it rotates the potentiometer also we
have another one on this side so we have two what happens is that when you move this back and forth
you can see here this is being rotated so we are rotating this potentiometer and the potentiometer
has three pins so when you rotate it actually you are putting the middle pin connecting to
this value and when you are rotating to the right it goes from five volt it comes to 0.5 and lower
so the value is between zero and one thousand twenty three so it's 1024 points so when it goes
left and right when you don't touch it it stays at the middle that's why we always see around
500 something so now this is the other one so it goes this way so when I move this back and
forth if I don't push it towards left or right the other one will not be affected so if I move
this if I move this like that so the other will not be affected but we can go somewhere
in between you see both of them are moving or at any position that you wish so both all of those
will be moving and we are we will be able to read the position of x and y then on this side
we have a switch so this is a switch that when you push the button so this is a push-button
switch which I have a separate video explaining it and this switch is connected to this pin now
in order to eliminate putting external resistor I've defined a pin as a pull-up professor which
I'm going to explain in the code so this is the joystick but the joystick is 26 millimeter 25.9
so that is 26 millimeter that's the width and the length of it after the 3.9 which is 34 a
millimeter and without that cup without this cup the depth here is fourteen point five millimeter
and if you want to know that are all depth including the cup 32 point two millimeters
you
so first from death five volts and the ground I have taken the blue the red here connected
to this pin of my breadboard and then the blue which is ground connected here in your breadboard
my blue might be the under other side so doesn't matter I'm putting it with the blue so this is the
ground and that red one is a five volts and then this is connected to the ground and five volts
in here these two are these pins now we have V or X and variable resistor x value register
why these two are directly connected to analog zero and analog one analog video analog one or
here a 0 and a 1 they have been labeled here as a 0 and a 1 so they are connected in here then
we have a switch for switch we need a digital pin so this is connected to pin sex on the on
this side so these are all digital pin between 2 to 13 so it's connected there if you want to
monitor the LED and if the switch is pressed then I used here parent 13 for the LED so the
that's coming to the led to the positive one which is a long one the long one is connected
to the pin 13 and then from the short one which is negative 680 ohm so anything less than 500
81-kilo will be fine because you just need to see the light and it goes here to the ground
so let me explain the code here we have defined a switch pin so pin sex you can put any digital
pin between 2 to 13 so you can ignore this it's not being used if you are not using a screen
and then inside the setup here we are setting the communication for 990 9600 baud and then here the
switch which is 6 this is as if I type sexier so input pull-ups we do not just type input
but pull up because we need if this we need this pin to be connected to a resistor with a pull-up
resistor to the positive so when you press it, it connects the ground and it acts for us so this is
very important otherwise you need extra wire and reserve to make it work and then pantry that's the
output this is optional if you need to display when the switch is pressed and display that LED
and then inside the loop which is thought from here to here a zero reads the input analog zero
and puts the value into X so this will be between 0 and 1000 23 and then a 1 is for the Y and again
these 2 are if you're using a screen otherwise you can ignore it but so this is the position
of X this is a position of Y if you are using the screen we say get the X which has a value between
0 and 1000 23 and then convert it or map it as the e-collar between 0 and the weight of the screen so
you don't have to do the calculation this will do it for you automatically so this is called map and
from one value minimum maximum to another value minimum maximum this value is defined in here
so if you are not used not using a screen you can just delete this and then here we
did digital digitalRead and the switch pan and the result of that would be stored in the S state
or switch so switch state and then here we are printing the text X and then the X actual X this
X without a quotation is the value of position of X and then we are printing this text because
this is inside the double could and then we are planting after the Y we are ending the position
of Y which is this one these X and that's why is planted and here we can say F which is low
when which means when it's pressed then press put this text on the screen I also set up in 13
too high so this will turn led on else otherwise turn the LED off and then wait for half a second
500 millisecond is wait for half a second and this repeats continuously so now let's have a look at
the code the value that you see is between the two values so this is 1023 and 1023 that we have okay
so it just prints x and y at a position so if I press this fully on this side you will see it
goes 1,000 23 23 for the y and back to the average which is at the middle 520 and if I go this way it
goes fully 0 so this back and forth which shows in this case it's Y so for the X the same thing
if I go here that goes 1023 leave it, it goes at the middle which is 500 and then the other way
would be zero so the x and y of this one is here correct but also it depends on your orientation
how you put it and now if I press this so this I'm pressing it and issues here and also here
when I press it also the LED is on and here is yours press now if you are using the screen that
I can use the exposition here instead of actual x value so Y position now let's say you have a
screen that has a width of 605 is 300 and you want to move not the screen or anything let's say you
you're pointing and laser beam on a wall and you are trying to draw something between 600 and 300
and so you can do that and here is the mapping that converts it and this time if I upload it
you will get the actual between the values of your screen so now you see the value this is the middle
of 600 so this is a 600 and the 300 is here for the Y so if I press this fully on this side you
can read this here that is 300 the maximum height of the screen and if I leave it it goes 0 and if
I go back so that is 0 at the middle leave it it will be hundred as 52 now this one will go between
0 and 600 if I polish it back it will be 600 leave it and then that's outside 0 0 so the mapping is
very useful to convert between the two values because 0 and 2 1023 might that might not mean
anything to you so put your own value and here you can just write the number which I typed it
there so it makes it very easy to understand for the application so this was introduction to this
dual axis joy sake please some of the video please share it and subscribe so we get updates when I
upload other videos that this will be used with different type of place thank you for watching
you