Robin2:
You did not post the code in which you removed that line.
#include <AccelStepper.h>
AccelStepper stepper1(AccelStepper::FULL4WIRE, 5, 6, 7, 8);
AccelStepper stepper2(AccelStepper::FULL4WIRE, 9, 10, 11, 12);
int movement = 360;
int start_var = 0;
void setup()
{
Serial.begin(9600);
stepper1.setMaxSpeed(200.0);
stepper1.setAcceleration(100.0);
//stepper1.moveTo(movement);
stepper2.setMaxSpeed(200.0);
stepper2.setAcceleration(100.0);
//stepper2.moveTo(movement);
}
char inBuffer = "";
void loop()
{
if(Serial.available()>0)
{
inBuffer = Serial.read();
}
if (inBuffer == 'a')
{
Serial.println("test point 1");
if (stepper1.distanceToGo() == 0)
stepper1.moveTo(-stepper1.currentPosition());
}
if (inBuffer == 'b')
{
Serial.println("test point 2");
if (stepper2.distanceToGo() == 0)
stepper2.moveTo(-stepper2.currentPosition());
}
stepper1.run();
stepper2.run();
inBuffer = "";
}
Commented them out from setup.
Robin2:
I don't like this style of codestepper1.moveTo(-stepper1.currentPosition());because you can't see the actual value that is being passed to moveTo()
If this was my project I would calculate the new moveTo value in a variable so I could print it if I needed to. Something like
newStepperPos = -stepper1.currentPosition;
stepper1.moveTo(newStepperPos);
That was how it came in the example program, am gonna leave it as it is for the moment. Thanks for the help!