OK I "think" I got it now. How does this look?
Will this have the over shooting issue & hit a mechanical limit & break?
#define POT_PIN A8
#define MAX_LEFT 750
#define MAX_RIGHT 300
int dir = 0; // 0 = Left, 1 = Right
void setup() {
Serial.begin(9600);
}
void loop() {
int headRot = analogRead(POT_PIN);
// Serial.println(headRot); // read-print pot
if (headRot < MAX_LEFT)
{
if (headRot > MAX_RIGHT)
{
// Serial.println("Center");
} else {
// Serial.println("Max Right");
dir = 0;
}
} else {
// Serial.println("Max Left");
dir = 1;
}
if (dir == 0)
{
Serial.println("Turning Left");
} else {
Serial.println("Turning Right");
}
}