Arduino JoyStick Module

From Geeetech Wiki
Jump to: navigation, search



Just like a joystick on game console. you can control x, y and z dimensions input by this joystick module. It can be considered as combination of potentiometers and one button. Data type of the x, y dimensions are analog input signals and z dimension is digital input signal. thus the x and y ports connect to analog pins of Sensor Shield, while z port connects to digital pin.

How this works

Joy sch.jpg

The joystick in the picture is nothing but two potentiometers that allow us to messure the movement of the stick in 2-D. Potentiometers are variable resistors and, in a way, they act as sensors providing us with a variable voltage depending on the rotation of the device around its shaft.

How to use

Joystick 1.jpg

When using, it can connect with Arduino sensor shield,and connect Arduino corresponding pins through Arduino sensor cables. In the example below, the X axes and Y axes are respectively link to the analog input A1 and A0 ,and Z axis is connected to the digital I/O 7 pin:

corresponding code

int sensorPin = 5;
int value = 0;
void setup() {
 pinMode(7, OUTPUT);
void loop() {
 value = analogRead(0);
 Serial.print(value, DEC);
 value = analogRead(1);
 Serial.print(" | Y:");
 Serial.print(value, DEC);
 value = digitalRead(7);
 Serial.print(" | Z: ");
 Serial.println(value, DEC);
Referring Sample Code :
int JoyStick_X = 0; //x
int JoyStick_Y = 1; //y
int JoyStick_Z = 3; //key
void setup() 
 pinMode(JoyStick_X, INPUT); 
 pinMode(JoyStick_Y, INPUT); 
 pinMode(JoyStick_Z, INPUT); 
 Serial.begin(9600); // 9600 bps
void loop() 
     int x,y,z;
     Serial.print(x ,DEC);
     Serial.print(y ,DEC);
     Serial.println(z ,DEC);

How to buy

Click here to buyArduino JoyStick Module