#include <Servo.h>
Servo servoA;
Servo servoB;
int servoPinA = 8;
int servoPinB = 6;
int servoAngleA = 0;
int servoAngleB = 0;
int xPin = A2;
int yPin = A1;
float xVal;
float yVal;
void setup() {
// put your setup code here, to run once:
servoA.attach(servoPinA);
servoB.attach(servoPinB);
pinMode(INPUT, xPin);
Serial.begin(9600);
servoA.write(servoAngleA);
servoB.write(servoAngleB);
}
void loop() {
// put your main code here, to run repeatedly:
xVal = analogRead(xPin);
yVal = analogRead(yPin);
servoAngleA = (1023-xVal) / 5.68333333;
servoAngleB = (1023-yVal) / 5.68333333;
if(servoAngleA != 89 || servoAngleB!=89)
{
Serial.println(servoAngleA);
Serial.println(servoAngleB);
Serial.println();
servoA.write(servoAngleA);
servoB.write(servoAngleB);
}
}