//Joystick Module//
Connection:-- We need 5 connections to the joystick.
The connection are : Key, Y, X, Voltage and Ground.
“Y and X” are Analog and “Key” is Digital. If you don’t need the switch then you can use only 4 pins.
Joystic module arduino Sample code:-
int xPin = A1;
int yPin = A0;
int buttonPin = 2;
int xPosition = 0;
int yPosition = 0;
int buttonState = 0;
void setup() {
// initialize serial communications at 9600 bps:
Serial.begin(9600);
pinMode(xPin, INPUT);
pinMode(yPin, INPUT);
//activate pull-up resistor on the push-button pin
pinMode(buttonPin, INPUT_PULLUP);
// For versions prior to Arduino 1.0.1
// pinMode(buttonPin, INPUT);
// digitalWrite(buttonPin, HIGH);
}
void loop() {
xPosition = analogRead(xPin);
yPosition = analogRead(yPin);
buttonState = digitalRead(buttonPin);
Serial.print("X: ");
Serial.print(xPosition);
Serial.print(" | Y: ");
Serial.print(yPosition);
Serial.print(" | Button: ");
Serial.println(buttonState);
delay(100); // add some delay between reads
}
Joystick Module
Joystick Module
Joystick Pinout
Joystick Module
Joystick Pinout
Pin Configuration
Pin No.
Pin Name
Description
Joystick Module Features
Two independent Potentiometer: one for each axis ( X and Y)
Auto return to center position
Low weight
Cup-type Knob
Compatible to interface with Arduino or with most microcontrollers
Joystic module Technical Specifications:-
Operating Voltage: 5V
Internal Potentiometer value: 10k
2.54mm pin interface leads
Dimensions: 1.57 in x 1.02 in x 1.26 in (4.0 cm x 2.6 cm x 3.2 cm)
Operating temperature: 0 to 70 °C
Internal Structure
The below image is the internal diagram of a Joystick Module. It consists of two Potentiometer, each for one axis (X and Y). Both 10k potentiometer are independent to move in their particular direction. SW (Switch) pin is connected to a push button internally.
Joystick Module Internal Structure:-
Where Joysticks Are Used?
When we listen the word “Joystick” we think of Game controllers. If we talk about Electronics there are many useful application of Joystick. These type of module are mostly used in Arduino based DIY projects and Robot Control. As we know, the module gives analog output so it can be used for feeding the analog input based on direction or movement. It can also be connected to a movable camera to control its movement.
How to Use Joystick?
We can use a Joystick Module with Arduino, Raspberry Pi and any other Micro-controllers. We just have to connect the axis Pins VRx and VRy to the ADC Pins of the micro-controller. If you want to use the switch then connect it to the digital Pin of the Micro-controller. Follow the below block diagram to connect Joystick Module with Microcontroller.
Joystick Module connection with Micro-controller:-
As used in many projects, the interfacing diagram of Joystick Module with the Arduino is given below. It helps you to connect the joystick Module with Arduino and get the analog output based on the direction of movement of Joystick Knob.
Joystick Module interfacing with Arduino:-
After Interfacing Joystick Module with the Arduino, we will get the analog output. The output range is fixed for each direction. The below image shows, the value of analog output for X and Y axis based on the movement of Joystick Module in all four directions (+X, -X, +Y, -Y). You will also get some analog value when moving the knob diagonally.
Joystick Module Analog Output:-
Application
Camera Pan/Tilt Control
Game Input/Control
Robot Control
Analog Input of Parameters
Widely use in DIY projects
2D-model
No comments:
Post a Comment