VEXcode, motor groups and drivetrain example

in the first example you do not have a condition that stops the motor. Setrotation merely sets the variable that represents how many rotations the motor has gone. What you are looking for is something like this

double current = motor.rotation(rev); // motor.setRotation(0,rev); also works for this scenario
wheelsLeftMain.spin(forward,30,percent);
wheelsRightMain.spin(forward,30,percent);
while(current + 1 >= motor.rotation(rev)){ // waits until motors have gone 1 revolution
    task::sleep(10);
}
motor.stop();

for the second example you are using blocking commands, meaning the code doesn’t execute anything else until the command is completed. The solution here is to add ‘false’ as your last parameter. This tells the brain to not wait for the completion of the rotations before continuing with the code.

5 Likes