Hi Dear group, first of all i want to thank you for your time and work making this library and answering questions here...
Im an arduino beginner, trying to get myself into accelstepper, and got somewhat confused between the different run() command variations. therefore 2 questions :
1. i have made a small table for reference, please tell me what should be in the "?", since i had some problem finding it by myself (see question 2)
| should
be executed constantly to move motor |
Blocking |
support acceleration |
COMMAND |
| V |
X |
V |
run() |
| V |
X |
X |
runSpeed() |
| ? |
V |
X |
runToPosition() |
| ? |
V (?) |
X |
runSpeedToPosition() |
2. i tried the runtoposition() command, which i understand should move the motor to position and stop ,
with a single call.the following code makes the motor spin constantly without moving, although i wanted it to stop after 1 revolution.
please tell me what wrong :
#include <
AccelStepper.h>
AccelStepper stepper(
AccelStepper::HALF4WIRE,8,10,9,11);
int steps=4076; //steps for 1 revolution
int flag=0;
void setup()
{
stepper.
setMaxSpeed(900);
}
void loop()
{
while (flag ==0 ) {
stepper.
moveTo(steps);
stepper.
setSpeed(900);
stepper.
runToPosition();
flag=1;
}
}