VEXcode Text

Can someone tell me if you can add multiple motors in one button? And paste their code if possible? Because our team is trying to do that, but when we do put two motors under one button, the remote controls (after we download the robot) switch and it is doing a totally different function, when we press a different button.

yes
if(Controller1.ButtonR1.pressing()) {
LA.spin(vex::directionType::rev, armSpeedPCT, vex::velocityUnits::pct); RA.spin(vex::directionType::rev, armSpeedPCT, vex::velocityUnits::pct);
}
else if(Controller1.ButtonR2.pressing()) {
LA.spin(vex::directionType::fwd, DownSpeedPCT, vex::velocityUnits::pct); RA.spin(vex::directionType::fwd, DownSpeedPCT, vex::velocityUnits::pct);
}
else {
LA.stop(vex::brakeType::hold); RA.stop(vex::brakeType::hold);
}

You could also motor group them in the motor and sensor setup section:
Example:

vex::motor_group arm (LA, RA)

if(Controller1.ButtonR1.pressing()) {
arm.spin(vex::directionType::rev, armSpeedPCT, vex::velocityUnits::pct);
}
else if(Controller1.ButtonR2.pressing()) {
arm.spin(vex::directionType::fwd, DownSpeedPCT, vex::velocityUnits::pct);
}
else {
arm.stop(vex::brakeType::hold);
}

1 Like