#include <EEPROM.h>
int VRx = A0;
int VRy = A1;
int VRy2 = A2;
int SW = 2;
int xPosition = 0;
int yPosition = 0;
int yPosition2 = 0;
int SW_state = 0;
int mapX = 0;
int mapY = 0;
int mapY2 = 0;
int potpin = 0;
// Include the Servo library
#include <Servo.h>
// Declare the Servo pin
int servoPin = 3;
int servoPin2 = 4;
int servoPin3 = 6;
// Create a servo object
Servo Servo1;
Servo Servo2;
Servo Servo3;
void setup() {
Serial.begin(9600);
pinMode(VRx, INPUT);
pinMode(VRy, INPUT);
pinMode(VRy2, INPUT);
pinMode(SW, INPUT_PULLUP);
// We need to attach the servo to the used pin number
Servo1.attach(servoPin);
Servo2.attach(servoPin2);
Servo3.attach(servoPin3);
pinMode(10, OUTPUT);
digitalWrite(10, HIGH);
}
void loop() {
xPosition = analogRead(VRx);
yPosition = analogRead(VRy);
yPosition2 = analogRead(VRy2);
SW_state = digitalRead(SW);
mapX = map(xPosition, 0, 1023, 0, 180);
mapY = map(yPosition, 0, 1023, 0, 180);
mapY2 = map(yPosition2, 0, 1023, 180, 0);
Servo1.write(mapX);
Servo2.write(mapY);
Servo3.write(mapY);
//Servo1.write(-mapX);
Serial.print("X: ");
Serial.print(mapX);
Serial.print(" | Y: ");
Serial.print(mapY);
Serial.print(" | Y2: ");
Serial.print(mapY2);
Serial.print(" | Button: ");
Serial.println(SW_state);
/*
if (mapX == 0)
{
Servo1.write(0);
};
if (mapX >= 250 && mapX < 400)
{
Servo1.write(72);
};
if (mapX >= 400)
{
Servo1.write(180);
};
if (mapX <= -250 && mapX > -400)
{
Servo1.write(-72);
};
if (mapX <= -400)
{
Servo1.write(-180);
};
delay(100);
*/
}