Im sure its alle wired up corectly but its not changing direction when I run the program-
The only way I can change direction is to change the wires around on one of the coils.
But I cant get the program to do it.
Im sure this is a very stupid question - sorry - I just started.
Witch is suposed to make the motor go back and forth. But it runs the same way - pauses and go same direction.
I do have step and direction pins conectet to 8 and 9 on the arduino.
I don't know anything about that AccelStepper library.
Any details?
Either way, I would check (voltmeter) the "step" and "dir" pins' status and connection.
void loop() {
digitalWrite(9, HIGH);
delayMicroseconds(100);
digitalWrite(9, LOW);
delayMicroseconds(100);
Distance = Distance + 1; // record this step
// Check to see if we are at the end of our move
if (Distance == 3600)
{
// We are! Reverse direction (invert DIR signal)
if (digitalRead(8) == LOW)
{
digitalWrite(8, HIGH);
}
else
{
digitalWrite(8, LOW);
}
// Reset our distance back to zero since we're
// starting a new move
Distance = 0;
// Now pause for half a second
delay(500);
}
}
I tried with another motor and its the same - so you are prop right. Must be the wires.