#include <Servo.h>
//Include the servo library
Servo servoX;
Servo servoY;
int joyX =0;
int joyY = 1;
int joyValX;
int joyValY;
void setup()
{ //attaches our servos on pin PWM 3
servoX.attach(3);
servoY.attach(5);
}
void loop()
{
//read the value of joystick (between 0-1023)
joyValX = analogRead(joyX);
joyValX = map (joyValX, 0, 1023, 0, 180); //servo value between 0-180
servoX.write(joyValX); //set the servo position according to the joystick value
joyValY = analogRead(joyY);
joyValY = map (joyValY, 0, 1023, 0, 180); //servo value between 0-180
servoY.write(joyValY); //set the servo position according to the joystick value
}