Tech
Forums
Jobs
Books
Events
Interviews
Live
More
Learn
Training
Career
Members
Videos
News
Blogs
Contribute
Article
Blog
Video
Ebook
Interview Question
Collapse
Feed
Dashboard
Wallet
Learn
Achievements
Network
Rewards
SharpGPT
Premium
Contribute
Article
Blog
Video
Ebook
Interview Question
Register
Login
How To Connect Arduino Joystick In Arduino Uno
WhatsApp
Sr Karthiga
4y
30.3k
0
2
100
Article
joystick.zip
Introduction
In this article, I am going to explain how to connect Arduino joystick in Arduino Uno. I am going to execute how the joystick will work with Arduino.
Parts of lists
Arduino Uno
Arduino joystick
Hook-Up wires.
Parts Explanation
Arduino joystick
Arduino joystick is a device that can be used to measure the X-axis, Y-axis and Z-axis direction. It is also called the game console. It can be considered as a combination of a potentiometer and one button.
Figure 1 - Arduino Joystick.
Connection
Connection to Arduino and Arduinojoystick.
Connect Vcc of joystick pin to the 5v of Arduino Uno.
Connect Gnd of joystick pin to the Gnd of Arduino Uno.
Connect I Rx of joystick pin to the 0 of Arduino Uno.
Connect I RY Vcc of joystick pin to the 1 of Arduino Uno.
Connect SW of joystick pin to the 2 of Arduino Uno.
Figure 2 - Connection
Programming
Count
int
SW - Pin = 2;
Count intX - Pin = 0;
Count intY - Pin = 1;
Void Setup() {
PinMode(SW - Pin.INPUT);
digitalwrite(SW - Pin, HIGH);
Serial.begin(115200);
}
Void loop() {
Serial.print(
"Switch: "
);
Serial.Print(4 digitalread(sw - pin));
Serial.print(\n);
Serial.print(
"X-axis: "
);
Serial.print(analogread(X - axis));
Serial.print(
"Y-axis: "
);
Serial.print(analogread(Y - axis));
Serial.print(
"\n\n"
);
delay(500);
}
Explanation
Joystick can show the direction i.e. the movement, which we had given, then it will show in the Serial monitor at what direction it was moving.
Subsequently, it can be used for major realtime projects like using truck and traffic signal direction, etc.
Output
Figure 3 - Output
Arduino Joystick
Arduino Uno
IoT
Up Next
Ebook Download
View all
Raspberry Pi -Sensorial Symphony of Connectivity
Read by 693 people
Download Now!
Learn
View all
Membership not found