#include <Servo.h>
int ServoHorizontalPin = 9;
int ServoVerticalPin = 10;
int HorizontalPotPin = A0;
int VerticalPotPin = A1;
int ServoH_Min = 0;
int ServoH_Max = 180;
int ServoV_Min = 0;
int ServoV_Max = 180;
Servo HorizontalServo;
Servo VerticalServo;
int HorizontalPotValue;
int HorizontalServoPosition;
int VerticalPotValue;
int VerticalServoPosition;
void setup()
{
Serial.begin(9600);
HorizontalServo.attach(ServoHorizontalPin);
VerticalServo.attach(ServoVerticalPin);
}
void loop()
{
HorizontalPotValue = analogRead(HorizontalPotPin);
VerticalPotValue = analogRead(VerticalPotPin);
HorizontalServoPosition = map(HorizontalPotValue, 0, 1023, ServoH_Min , ServoH_Max);
VerticalServoPosition = map(VerticalPotValue, 0, 1023, ServoV_Min , ServoV_Max);
HorizontalServo.write(HorizontalServoPosition);
VerticalServo.write(VerticalServoPosition);
delay(20);
Serial.print("X-axis: ");
Serial.print(HorizontalPotValue);
Serial.print(" | ");
Serial.print("Y-axis: ");
Serial.print(VerticalPotValue);
Serial.println(" | ");
}