I am beginner. So I started to experiment with arduino and accelstepper library and just want to make simple movements with stepper motor (28BYJ-48). I want Stepper to move 500 positions forward, than back to 0, then forward to 300. I started trying to make stepper move 500 forward with this code:
void setup()
{
// Change these to suit your stepper if you want
stepper.setMaxSpeed(2000);
stepper.setAcceleration(20);
}
void loop()
{
stepper.moveTo(500);
stepper.run();
This is fine. Stepper rotates to 500 and stops. I add another part of code and this working fine. stepper rotates back to 0:
stepper.setMaxSpeed(2000);
stepper.setAcceleration(20);
stepper.moveTo(0);
stepper.run();
But when I add third part of code the stepper is not working as supposed to. It will rotate 500, then stops and start rotate very slowly. What is happening? I just added the similar part of code, only with other numbers. There is the whole code:
void setup()
{
// Change these to suit your stepper if you want
stepper.setMaxSpeed(2000);
stepper.setAcceleration(20);
}
void loop()
{
stepper.moveTo(500);
stepper.run();
stepper.setMaxSpeed(2000);
stepper.setAcceleration(20);
stepper.moveTo(0);
stepper.run();
stepper.setMaxSpeed(2000);
stepper.setAcceleration(20);
stepper.moveTo(300);
stepper.run();
Thank you for your help.