Close

JOYSTICK WITH ARDUINO

adnanansari9580adnan.ansari9580 wrote 02/22/2020 at 15:22 • 5 min read • Like

JOYSTICK:-

INTRODUCTION:-

Analog Joystick is not any type but it is a type of switch or simple components attached or joined together to form a Joystick. It is not as same as most of you might have an Xbox one or some gamepad controller, it is similar to that bot can’t say exactly that. These types of joystick are very basic one and easily available and are used in variety of projects for making moveable pointers like mouse.

We can combine few more components with this joystick to make our own gamepad controller, that will be discussed in the future post. There are better working and more advanced versions of it the one which I am using is easily available and easy to use as always.

DESCRIPTION:-

Analog Joystick is a combination of two 10 k  potentiometer or variable resistor. It is not built out of any IC (integrated circuit’s) but only two pot for X & Y axis and a pus button for selection.

It has only 5 pin out of which two are analog output, 1 digital or analog output and two power inlets.

*NOTE:- THIS SENSOR IS  NOT THE BEST ONE TO USE FOR PROFESSIONAL THINGS , IT CAN ONLY BE USED TO MAKE SOME SAMLL PROJECTS.

 

This sensor gives the output of both type ANALOG and DIGITAL. Difference b/w analog and digital signal is that in the digital signal only high state or low state is given but in the analog signal values b/w 0-1023 is given which is more suitable for condition in the code. The axis coordinates or the analog values are given in values between 0-1023 and pushbutton can be used to give output of both analog and digital type.

FEATURES AND APPLICATIONS:-

SENSOR SPECIFICATIONS:-

COMPONENTS NEEDED:-

CIRCUIT DIAGRAM:-

 

First take the power lines onto the bread board from microcontroller

VCC/5v-->+ line and GND--> - line.

Then connect the sensor on to the bread board and connect power to the JOYSTICK from powerlines using male to female jumper wires.

Now connect VRx PIN OF JOYSTICK TO MICROCONTROLLER ANALOG PIN A0 and VRy PIN OF THE JOYSTICK TO THE MICROCONTROLLER ANALOG PIN A1, SW PIN OF JOYSTICK TO DIGITAL (PIN 2) OF THE MICROCONTROLLER.

Now connect two leds to the breadboard –  to gnd and + to digital pin 3 and 4 of the microcontroller.

CODE:-

//put this code in the ide of arduino from this line

 int xaxis=A0; //initializing the analog pin for VRx

 int yaxis=A1; //initializing the analog pin for VRy

 int led1=A2; // initializing led pin for VRx

 int led1=A3; // initializing led pin for VRy

 int value1;

 int value2;

void setup(){

 Serial.begin(9600);

pinMode(xaxis, INPUT); // assign the pin mode type of the pin as input or output

pinMode(yaxis, INPUT); // assign the pin mode type of the pin as input or output

pinMode(led1, OUTPUT);

pinMode(led2, OUTPUT);

}

void loop(){

value1=analogRead(xaxis); //reading the values from the JOYSTICK

value2=analogRead(yaxis); //reading the values from the JOYSTICK

analogWrite(xaxis, value1);

analogWrite(yaxis, value2);

}

WORKING:-

As the code starts it initializes the pin to which the JOYSTICK send the coordinated to the microcontroller. On receiving the analog signal the microcontroller send these values to the analog pin 2 and 3 to glow the led according to the analog value

PCB DESIGNING:-

Now we have got the PCB design and it’s time to order the PCB’s. For that, you just have to go to JLCPCB.com, and click on “QUOTE NOW” button.

JLCPCB are also sponsor of this project. JLCPCB (ShenzhenJLC Electronics Co., Ltd.), is the largest PCB prototype enterprise in Chinaand a high-tech manufacturer specializing in quick PCB prototype and small-batch PCB production. You can order a minimum of 5 PCBs for just $2.

To get the PCB manufactured, upload the gerber file you downloaded in the last step. Upload the.zip file or you can also drag and drop the gerber files.

After uploading the zip file, you’ll see a success message at the bottom if the file is successfully uploaded.You can review the PCB in the Gerber viewer to make sure everything is good. You can view both top and bottom of the PCB.

After making sure our PCB looks good, we can now place the order at a reasonable price. You can order 5 PCBs for just $2 but if it’s your first order then you can get 10 PCBs for $2.

To place the order, click on “SAVE TO CART” button.

My PCBs took 2 days to get manufactured and arrived within a week using DHL delivery option. PCBs were well packed and the quality was really good.

*NOTE:- If you need pcb gor this project than contact me or write me in the comment.

Like

Discussions