read the pot
use map to limit its value to -90 - 90
the abs() is the PWM
determine the sign which is the direction of one motor and the opposite sign the direction of the other
void range (
int x)
{
int val = map (x, 0,1023, -90, 90);
int dirA = val / abs(val);
int dirB = - dirA;
val = abs(val);
char s [80];
sprintf (s, " %6d %4d %2d %2d", x, val, dirA, dirB);
Serial.println (s);
}
// -----------------------------------------------------------------------------
void loop()
{
// int pot = analogRead (A0);
delay (200);
}
// -----------------------------------------------------------------------------
void setup()
{
Serial.begin(115200);
for (int x = 0; x <= 1024; x += 128)
range (x);
}