#include <Servo.h>

#define VERT_PIN A0
#define HORZ_PIN A1
#define SEL_PIN  A3
Servo servo1; // Create a "Servo" object called "arm"
Servo servo2; // Create a "Servo" object called "arm"

void setup() {
  pinMode(VERT_PIN, INPUT);
  pinMode(HORZ_PIN, INPUT);
  pinMode(SEL_PIN, INPUT_PULLUP);
 
  servo1.attach(11); // Attache the arm to the pin 2
  servo1.write(0);
   servo2.attach(10); // Attache the arm to the pin 2
  servo2.write(0);


}

void loop() {
  int vert = analogRead(VERT_PIN);
  int horz = analogRead(HORZ_PIN);
  bool selPressed = digitalRead(SEL_PIN) == LOW;
  int h=map(analogRead(HORZ_PIN), 0, 1023, 0, 180);
  int v=map(analogRead(VERT_PIN), 0, 1023, 0, 180);
  servo1.write(h);
  servo2.write(v);
if(selPressed){
  for(int i=0;i<=180;i++){
   servo1.write(i);
   servo2.write(i);
  }
  delay(500);

}
  // horz goes from 0 (right) to 1023 (left)
  // vert goes from 0 (bottom) to 1023 (top)
  // selPressed is true is the joystick is pressed
}