Dears, I am connecting a stepper motor to arduino Mega, and I am trying to set the stepper mottor position to 100 when pressing to c and when it's in the position 100 I want to return to the default position which is 0. However it is not working. Stepper motor is moving few steps slowly and do not get to the normal position. Kindly help
while (input_m=='c') {
stepperM.stop();
stepperT.moveTo(100);
stepperT.setSpeed(200);
stepperT.runSpeedToPosition();
if (stepperT.targetPosition()==100) {
stepperM.setSpeed(-motorSpeed_m);
stepperM.moveTo(-steps_inv_m);
stepperM.runToPosition();
stepperT.moveTo(0);
stepperT.setSpeed(200);
stepperT.runSpeedToPosition();
input_m= '0';
Serial.print("Finish \n");
Serial.println("");
break;
}
}