Arduino Joystick Demo

 


 int joyPin1 = A0;                 // slider variable connected to analog pin 0
 int joyPin2 = A1;                 // slider variable connected to analog pin 1
 int value1 = 0;                  // variable to read the value from the analog pin 0
 int value2 = 0;                  // variable to read the value from the analog pin 1

 void setup() {
  pinMode(joyPin1, INPUT);              
  pinMode(joyPin2, INPUT); 
  Serial.begin(9600);
 }

 void loop() {
  value1 = analogRead(joyPin1);             
  value2 = analogRead(joyPin2);  

  delay(100);
  Serial.print("Pin1: ");
  Serial.print(value1);
  Serial.print(" Pin2: ");
  Serial.println(value2);
}

Source.