Why not do something simple and obvious like this
void loop()
{
if(Serial.available()>0) // If any information is avaiable coming from the serial monitor
{
inBuffer = Serial.read(); // Puts the information coming from the serial monitor in the input buffer
}
if (inBuffer == 'a') // If the command sent is an 'a'
{
Serial.println("test point 1"); //Serial print for test point 1
if (stepper1.distanceToGo() == 0) {
if (stepper1.currentPosition() == 0) {
stepper1.moveTo(movement);
}
else {
stepper1.moveTo(0);
}
}
if (stepper2.distanceToGo() == 0) {
if (stepper2.currentPosition() == 0) {
stepper2.moveTo(movement);
}
else {
stepper2.moveTo(0);
}
}
inBuffer = ""; // clear this immediately the 'a' has been used
}
stepper1.run();
stepper2.run();
}
...R