Vex 4 motor tank drive infinite loop

Can anyone assist me on why this is running an infinite loop

void driveForward(double value ) {

while ( value <= 1){
value = value *0.082;
LM1.spin(vex::directionType::fwd, 80, vex::velocityUnits::pct);
LM2.spin(vex::directionType::fwd, 80, vex::velocityUnits::pct);
RM1.spin(vex::directionType::rev, 80, vex::velocityUnits::pct);
RM2.spin(vex::directionType::rev, 80, vex::velocityUnits::pct);
}
LM1.stop(vex::coast);
LM2.stop(vex::coast);
RM1.stop(vex::coast);
RM2.stop(vex::coast);

}

the value was .01 at the bottom so it isnt that

Is value a double or an integer?

Also you have an unmatched bracket at the end, assuming it’s not connected to something else.

What value are you using when u call the function?

Work out the math.

Assume value starts at 1 or less. We’ll choose 1 for the example.

Is 1 <= 1? Yes, so run the loop. Change value to value * 0.082, so 1 * 0.082 = 0.082.

Is 0.082 <= 1? Yes, so run the loop. Change the value to value * 0.082, so 0.082 * 0.082 = 0.0064…

Is 0.0064 <=1? Yes…

You wrote a condition and loop that will never result in the condition being false if it is ever true once.

4 Likes

Ok thanks for the suggestion ill try to work it out