While loops and the && operator

Hi, sorry for the basic question but I’m having trouble with a while loop…

I’m driving two stepper motors and would like the first to rotate 180 degrees, and the second to rotate 270 degrees. I would like the while loop to run until both motors have reached their target position, but it seems that once motor1 reaches it’s position, it exits the loop and motor2 has not reached its target position.

What am I missing? Is there something about while loops or the && operator that I don’t understand?

#define STEPS1 (180*3)  // range of motion for speedometer gauge motor
#define STEPS2 (270*3)  // range of motion for input_8 gauge motor
// sweep motors through full range of motion
  motor1.targetStep = STEPS1;
  motor2.targetStep = STEPS2;
  while (motor1.currentStep < STEPS1 && motor2.currentStep < STEPS2) 

I think you need a logical or (||) instead of a logical and (&&). With your current code the while is finished if one of the conditions is false (e.g. motor1.currentStep >= STEPS1) while the other is not yet complete.

Ok that worked. Thank you. Stupid error on my part, I think I understand it now.