# How Do you get Two Motor Groups to move simultaneously in auton?

I’m using this code rn but it’s causing it to spin one for the time then the next, would I have to set all the motors into a auton specific motor group? Here’s the code I’m currently using that doesn’t work.
RightDrive.setVelocity(100, percent);
LeftDrive.setVelocity(100, percent);
RightDrive.rotateFor(reverse, 42, rotationUnits::rev) && LeftDrive.rotateFor(reverse, 42, rotationUnits::rev);

does one motor spin then another?

RightDrive.setVelocity(100, percent);
LeftDrive.setVelocity(100, percent);
RightDrive.rotateFor(reverse, 42, rotationUnits::rev) && LeftDrive.rotateFor(reverse, 42, rotationUnits::rev, false);
leftDrive.rotateFor(reverse, 42, rotationUnits::rev) && LeftDrive.rotateFor(reverse, 42, rotationUnits::rev, false);

1 Like

yes, one spins then the next.

I believe there may be a typo here, you have an open parenthesis, that won’t work in v5 code pro.

A motor can be part of multiple motor groups

``````motor frontLeft(PORT1);
motor backLeft(PORT2);
motor_group leftDrive(frontLeft, backLeft);

motor frontRight(PORT3);
motor backRight(PORT4);
motor_group rightDrive(frontRight, backRight);

motor_group driveMotors(frontLeft, backLeft, frontRight, backRight);``````
``````driveMotors.setVelocity(100, percent);
driveMotors.spinFor(reverse, 42, rotationUnits::rev);``````

the issue is turning, we need to be able to control the two sides of the drive to be able to turn without moving the bot’s center

The `robot.spinFor` function (and other motor functions) has a 5th optional parameter called waitForCompletion. If you set this to false then your code won’t wait for the motor to stop moving. This allows you to do something like this:

``````Right.spinFor(-180, degrees, 90, percent, false);
Left.spinFor(180, degrees, 90, percent);
``````

This will spin them both at the same time, and continue with your code after the left motor finishes

1 Like