# 10.1 Joystick

## Hardware Wiring

![Joystick](https://2341898987-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LCFDbcteyTR3tQSs-5x%2F-LCFE4dCRQBMq1ajywfh%2F-LCFERHj0U2nxdQqnbQB%2F020_joystick.jpg?generation=1526059617282432\&alt=media)

## Sketch

The code can be found at [Examples\_Arduino - sensor-kit-for-arduino - \_020\_Joystick - \_020\_Joystick.ino](https://github.com/LongerVisionRobot/Examples_Arduino/blob/master/sensor-kit-for-arduino/_020_Joystick/_020_Joystick.ino).

```
int sensorPin = 5;
int value = 0;
void setup() {
  pinMode(7, OUTPUT);
  Serial.begin(9600);
}
void loop() {
  value = analogRead(0);
  Serial.print("X:");
  Serial.print(value, DEC);
  value = analogRead(1);
  Serial.print(" | Y:");
  Serial.print(value, DEC);
  value = digitalRead(7);
  Serial.print(" | Z: ");
  Serial.println(value, DEC);
  delay(100);
}
```
