While Loop Help

I am attempting to have my claw oscillate while the intake is running, I assumed a while loop would work yet it seems to not be running the while loop even if the conditions are met.
Code-

void driverControl(){
  while(true){
  while (ClawWheels.isSpinning() == true){
   Controller1.Screen.print(0);
  ClawRotate.spinFor(forward, 60,degrees);
   }
 if(Controller1.ButtonY.pressing()){;
ClawWheels.spin(forward,100, percent);
 }

The print is just to check if the loop is running

I suspect you think isSpinning() means the motors are moving. isSpinning() is only true when the motor is moving to a target position, ie. a spinFor or spinTo is still executing.

1 Like

A while loop is a yielding function. That basically means that anything in a while() would run and nothing outside of the while() will run, so long as the condition is met. In driver control you traditionally only have one while loop. I believe you should be only using an if statement. Also if the motor is spinning I am unsure if it is not your intention to command the motor to spin for 60 degrees every 5 or so milliseconds because that is what the code is doing in the inner while loop.

1 Like