This Thumb Joystick is a analog joystick controller that has X and Y axes values using 10k potentiometers which give you 2D movement by generating analog signals. This joystick has also a single push button that could be used for special application, can be use as on of off instruction going to the microcontroller. This module will works output analog and digital values, this 2 analog output represent the location of the two potentiometers and the digital output. I will demonstrate to you below how to use and program this module using Arduino UNO.
Wiring to Arduino UNO.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
/* Joystick demo connect the module X<->A0;Y<->A1 and K<-> D3; */ void setup() { Serial.begin(9600); // Enable Serial Communication } void loop() { int sensorValue1 = analogRead(A0); int sensorValue2 = analogRead(A1); int sensorK = digitalRead(D3) Serial.print("The X and Y coordinate is:"); Serial.print(sensorValue1, DEC); Serial.print(","); Serial.println(sensorValue2, DEC); Serial.println(" "); delay(200); } |
How to use the Joystick module in Arduino