Hi Dear forum
Im trying to understand the Accelstepper library and the diffrence between some commands.
for this purpose im writing small diffrent sketches , each with other command, to see if i get the idea.
For some reason, the runToPosition() command is not working as i understand it .
also im somwhat confused between run(), runspeed(), runtoposition(), runspeedtoposition()...
will be glad for a brief explanation of the diffrences- i understand some of them implement accelaration, some are not, some are blocking,some are not, but its not stated clearly for each function.
here is the explanation of runtoposition() command in the accelstepper documantation:
"Moves the motor at the currently selected constant speed (forward or reverse) to the target position and blocks until it is at position. Dont use this in event loops, since it blocks."
i wrote a small sketch , which (for my understanding) supposed to spin the motor 1 revolution and stop.
what happens is that the motor spins constantly, and actually never gets past the runToPosition() command, although it got to its position. here is the skecth, please help ...
// Blue - 28BYJ48 pin 1 - PIN 8
// Pink - 28BYJ48 pin 2-PIN 9
// Yellow - 28BYJ48 pin 3-PIN 10
// Orange - 28BYJ48 pin 4-PIN 11
// Red - 28BYJ48 pin 5 (VCC)#include <AccelStepper.h>
AccelStepper stepper(AccelStepper::HALF4WIRE,8,10,9,11); // Defaults to AccelStepper::FULL4WIRE (4 pins) on 2, 3, 4, 5
int steps=4076;
int flag=0;
void setup()
{
stepper.setMaxSpeed(900);
Serial.begin(9600);
}void loop()
{while (flag ==0 ) { //supposed to be runned once !
stepper.moveTo(steps);
stepper.setSpeed(900);
stepper.runToPosition();
//supposed to run motor to position per moveto command
//and then stop and continue to next code line ??
flag=1;
}}