I am looking a creating a stepper motor with forwards and reverse using arrays however I am having trouble getting it to reverse. What do I need to change to get it to step backwards?
What stepper motor and stepper driver? How is the motor powered?
What have you tried (post code and schematic)? What happened ("didn't work" is not an answer)?
for (int step = 7; step >= 0; step--) {
delay(500);
for (int pin = 3; pin >= 0; pin--) {
digitalWrite(stepperPin[pin], stepSequence[step][pin]);
use the </> to post code
assuming that each 4 value sequence indicates A, A', B, B', i don't think it makes sense for both pairs to have the same state (i.e. A=A' and B=B'
i believe the simplest sequence is just 4 states
{ HIGH, LOW, HIGH, LOW },
{ LOW, HIGH, HIGH, LOW },
{ LOW, HIGH, LOW, HIGH },
{ HIGH, LOW, LOW, HIGH }
sequence on left
for such a sequence, reversing the motor requires going backwards in the sequence
i think you were attempting a sequence with half steps
{ HIGH, LOW, LOW, LOW },
{ HIGH, LOW, HIGH, LOW },
{ LOW, LOW, HIGH, LOW },
{ LOW, HIGH, HIGH, LOW },
{ LOW, HIGH, LOW, LOW },
{ LOW, HIGH, LOW, HIGH },
{ LOW, LOW, LOW, HIGH },
{ HIGH, LOW, LOW, HIGH },
This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.