#include <Servo.h>
Servo servo1; // Servo for X-axis control
Servo servo2; // Servo for Y-axis control
void setup() {
servo1.attach(9); // Attach servo1 to pin 7
servo2.attach(10); // Attach servo2 to pin 6
}
void loop() {
// Read joystick positions
int xPosition = analogRead(A0); // X-axis
int yPosition = analogRead(A3); // Y-axis
// Map joystick values (0-1023) to servo positions (0-180 degrees)
int servo1Position = map(xPosition, 0, 1023, 0, 180);
int servo2Position = map(yPosition, 0, 1023, 0, 180);
// Write the mapped values to the servos
servo1.write(servo1Position);
// Slow down the Y-axis servo by adding an additional delay
delay(100); // Adjust this value to control the speed of the Y-axis servo
servo2.write(servo2Position);
// Small delay to allow for servo movement and to reduce "jitter"
delay(15);
}