Go Down

Topic: Accel stepper library with support for 28byj-48 motor (Read 28562 times) previous topic - next topic

arepaziz23


Robin2

If you indent your code consistently it is easier to see the problem
Code: [Select]
void loop()
{
       // Change direction at the limits
    if (stepper3.distanceToGo () == 0) {
        stepper3.moveTo(1700);
    }
    stepper3.run();
    stepper3.moveTo(0);
    stepper3.run();
}


The command stepper3.run() is what makes the motor move and it must be called more often than the motor needs to take steps. It does not implement the entire move with one call. For that you need the blocking function runToPosition()

The way your code is written, as soon as you set the distance to 1700 you set it back to 0.

Try this variation and see what happens
Code: [Select]
void loop()
{
       // Change direction at the limits
    if (stepper3.distanceToGo () == 0) {
        stepper3.moveTo(1700);
    }
    stepper3.run();

}


...R
Two or three hours spent thinking and reading documentation solves most programming problems.

Go Up