#include <Servo.h>

Servo servoX;  // create servo object to control the X-axis servo
Servo servoY;  // create servo object to control the Y-axis servo

int joystickPinX = A0;  // analog input pin for X-axis joystick
int joystickPinY = A1;  // analog input pin for Y-axis joystick

int servoXPin = 5;  // PWM pin for X-axis servo
int servoYPin = 3; // PWM pin for Y-axis servo

int joystickX;  // variable to store X-axis joystick value
int joystickY;  // variable to store Y-axis joystick value

void setup() {
  servoX.attach(servoXPin);  // attach the X-axis servo to its pin
  servoY.attach(servoYPin);  // attach the Y-axis servo to its pin
}

void loop() {
  joystickX = analogRead(joystickPinX);  // read X-axis joystick value
  joystickY = analogRead(joystickPinY);  // read Y-axis joystick value

  // map joystick values to servo angles
  int servoXAngle = map(joystickX, 0, 1023, 0, 180);
  int servoYAngle = map(joystickY, 0, 1023, 0, 180);

  // control the servos
  servoX.write(servoXAngle);
  servoY.write(servoYAngle);

  delay(15);  // a short delay to stabilize the servos
}