I’m unable to get two motors to spin at the same time for my autonomous. I have a competition tomorrow any help is helpful 
here’s my code
“-----------------------------------------------------------------------------------------------”
void autonomous(void) {
while(true){
LeftMotor.setVelocity(100, percent);
LeftMotor2.setVelocity(100, percent);
RightMotor.setVelocity(100, percent);
RightMotor2.setVelocity(100, percent);
LeftMotor.spinFor(fwd, 2, seconds);
LeftMotor2.spinFor(fwd, 2, seconds);
RightMotor.spinFor(fwd, 2, seconds);
RightMotor2.spinFor(fwd, 2, seconds);
}
}
“-----------------------------------------------------------------------------------------------”
when you use spin for it’s going to yield the script until that statement is finished then it will move onto the next line. Add a 4th parameter, false.
LeftMotor.spinFor(fwd, 2, seconds, false);
that gives me a bunch of errors
Whats the exact problem. Are no motors spinning, only 2. Are they spinning in opposite directions? If theyre spinning in opposite directions reverse 2 of your motors
Sorry I was thinking of something else. If you want to spin the motors for a certain amount of time do this
LeftMotor.spin(fwd);
LeftMotor2.spin(fwd);
RightMotor.spin(fwd);
RightMotor2.spin(fwd);
wait(2, sec)
leftMotor.stop()
LeftMotor2.stop()
RightMotor.stop()
RightMotor2.stop()
only one motor spins at a time
The above code should definitely work. Did you adjust the motor names and add semicolons as needed?
so when i try that all the motors spin but now i cant get them to stop. my wait does not turn yellow it just turns white as soon as i input anything
are you able to get a screenshot because this works fine for me.
what messages did you get in the debugger/error checker?
I’m not sure why you have the infinite while loop at the beginning of your code. I don’t know if that is the problem but I don’t think you need that in Auton,
1 Like