#include <Servo.h>
Servo Xservo;
Servo Yservo;
int xPin = A1;
int yPin = A0;
int sPin = 2;
int xSpin = 9;
int ySpin = 10;
int buzzPin = 7;
float xVal;
float yVal;
float WVx;
float WVy;
int sVal;
int dt = 250;
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
pinMode(xPin, INPUT);
pinMode(yPin, INPUT);
pinMode(sPin, INPUT);
pinMode(xSpin, OUTPUT);
pinMode(ySpin, OUTPUT);
pinMode(buzzPin, OUTPUT);
Xservo.attach(xSpin);
Yservo.attach(ySpin);
digitalWrite(sPin, HIGH);
}
void loop() {
// put your main code here, to run repeatedly:
xVal = analogRead(xPin);
WVx = (180./1023.)*xVal;
yVal = analogRead(yPin);
WVy = (180./1023.)*yVal;
sVal = digitalRead(sPin);
Xservo.write(WVx);
Yservo.write(WVy);
delay(dt);
Serial.print("X Value = ");
Serial.print(xVal);
Serial.print(" Y Value = ");
Serial.print(yVal);
Serial.print(" Switch State is ");
Serial.println(sVal);
Serial.println(WVx);
delay(250);
Serial.println(WVy);
delay(250);
}