Get multiple motors to move with one button

How would I get multiple motors to move a certain degrees with the press of a button. Currently they will spin one at a time.

  while(Controller1.ButtonX.pressing()){
   Lift.rotateFor(directionType::rev,90,rotationUnits::deg,100,velocityUnits::pct);
   IntakeLeft.rotateFor(directionType::fwd,90,rotationUnits::deg,100,velocityUnits::pct);
   IntakeRight.rotateFor(directionType::fwd,90,rotationUnits::deg,100,velocityUnits::pct);         
  }

One thing you could do is use tasks to run them all at once, I don’t know if there is another way as I haven’t programmed much with vex code yet.

Use an if statement. It should look something like this
If(controllerpessing) {
Motor rotate to
}
Else if (controllerpessing) {
Motor rotate to
}
Else {
Motor brake
}
Make sure to do the else part or the motor will continue to rotate

one way to do it is to create a motor group

you need to change the first rotateFor to “non-blocking” by inserting a false at the end.

while(Controller1.ButtonX.pressing()){
Lift.rotateFor(directionType::rev,90,rotationUnits::deg,100,velocityUnits::pct , false);
IntakeLeft.rotateFor(directionType::fwd,90,rotationUnits::deg,100,velocityUnits::pct ,false);
IntakeRight.rotateFor(directionType::fwd,90,rotationUnits::deg,100,velocityUnits::pct);
}

3 Likes

What is the format to do this VexCode 1.0?

Should be that format mentioned up there. You could also probably just copy/paste that into your code.

You have to make this code non-blocking by adding false at the end because VEXcode defaults it to true so it would look more like
Lift.rotateFor(directionType::rev,90,rotationUnits::deg,100,velocityUnits::pct,false);

1 Like

To everyone that put false, I tried that before, but it just gave me a compile error, we used time which isnt very good but it works for now before our first tournament. I plan on switching to pros, but I can’t seem to get it to work in general right now so I’ve stuck with vex coding studio for now.

Could you maybe post your code now?

I will do as soon as I can.