Yes, if I run the code below, the motor runs as expected.
In one direct for 4 sec. then in the other for 4 sec.....
//Motor A
int dir1PinA = 2;
int dir2PinA = 3;
int speedPinA = 5;
unsigned long time;
int speed;
int dir;
void setup ()
{
pinMode (dir1PinA, OUTPUT);
pinMode (dir2PinA, OUTPUT);
pinMode (speedPinA, OUTPUT);
time = millis ();
speed = 200;
dir = 1;
}
void loop ()
{
analogWrite (speedPinA, speed);
// set direction
if (1 == dir)
{
digitalWrite (dir1PinA , LOW);
digitalWrite (dir2PinA, HIGH);
}
else
{
digitalWrite (dir1PinA, HIGH);
digitalWrite (dir2PinA, LOW);
}
delay(4000);
if (1 == dir)
{dir = 0;}
else
{dir = 1;}
}
It's just the logic with the pot code that I can't figure out.