2 motors in 3 differents(revense, foward, or both)

How I put 3 differents in 2 motors on vexcode pro. Two motors use only reverse, only forward, or one is forward and other one is reverse.

2 motors have 2 differents. It was works. :
if (Controller1.ButtonR1.pressing()) {
TopOfPass.spin(directionType::fwd, velocity, velocityUnits::pct);
BottomOfPass.spin(directionType::fwd, velocity, velocityUnits::pct);
}
else if (Controller1.ButtonR2.pressing()) {
TopOfPass.spin(directionType::rev, velocity, velocityUnits::pct);
BottomOfPass.spin(directionType::rev, velocity, velocityUnits::pct);
}
else {
TopOfPass.stop(brakeType::coast);
BottomOfPass.stop(brakeType::brake);
}

2 motors have 3 differents. It was not work.
Annotation 2020-11-10 120751

I want 2 motors have 3 differents but how i put it then it work?

You should use one big chain of if ... else if statements, with only one else case at the end.

With your current code, consider what happens if you press only button R1. Then the first if .. else if ... else statement tells both motors to spin forward, and the second if ... elsestatement tells both motors to stop. Telling motors to both spin and stop at the same time will cause undesired behavior.

If you instead structure your code like this:

if (Controller1.ButtonR1.pressing()){
    // spin both motors forward
}
else if (Controller1.ButtonR2.pressing()){
    // spin both motors backward
}
else if (Controller1.ButtonLeft.pressing()){
    // spin one motor forward and the other backward
}
else{
    // stop both motors
}

then you’ll only be telling the motors to do one thing at once.

8 Likes

I understand clearly. Thank you for help.

1 Like

Is there a way to have 2 different intakes spin at the the same time by pressing L1 when my robots tray is down but when the tray is up one intake spins when pressing L1 and the othe spins when pressing R1?

Sure, an if statement should do the trick:

if(tray is down) {
  code for when tray is down
} else if (tray is up) {
  code for when tray is up
}
2 Likes

Thank you for helping me

1 Like

How many motors are allowed this year

In VRC you get 8 motors, or 6 with pneumatics

All info on rules is in the game manual: https://content.vexrobotics.com/docs/vrc-change-up/VRC-Game-Manual-10012020.pdf

3 Likes

Can you explain to me what pneumatics are in detail sorry if asking you all these questions is annoying you im just trying to get help

No problem, pneumatics basically use compressed air to extend or retract a piston: https://www.vexrobotics.com/pneumatics.html

I don’t recommend using pneumatics in VRC because of how much they limit your motors, especially if you’re just starting out. Also because they really are not useful for this game.

3 Likes