Programming Motors VEX Code Pros

We are trying to programming our friction rubber band intake to spin one of the intake sets in reverse to push a ball out the back of the robot. We are using two motors. I front motor and a rear motor on the intake system. We want them to both run on the R1 button and have them set up to spin opposite each other using chains and gears. The program works successfully, however, we want to push the A button to make the one motor turn the opposite direction of the others to force the ball out the back of the robot. We want this to work during driver control.
Thoughts?

can you send a picture of your roller setup?

1 Like

Often, it can be instructional to write out psuedocode to understand the logic of what you want before writing code that compiles.

Your text above, strictly, seems to say that Motor 1 and Motor 2 should always spin the opposite direction, but I don’t think that is what you mean. This pseudocode may do what you intend:

while userControl:
  if buttonR1 is pressed:
    Spin Motor1 forward
    Spin Motor2 backwards
  else if buttonA is pressed:
   Spin Motor1 forward
   Spin Motor2 forward
  else
    Do not spin Motor1
    Do not spin Motor2
4 Likes

If you want to press button A to force the ball out of the back you would have a helper function like

void reverseMotor() {
    Motor.spin(rev);
}

and have a call back function in the while loop that runs the above code when the button is pressed

Controller1.ButtonA.pressed (reverseMotor);

If you want to be pressing and holding down on button A while it ejects then in the while loop you would do something like

if( Controller1.ButtonA.pressing ) {
reverseMotor();
}
1 Like

Since you are
using vexcode pro v5, I have a question. What is the difference between vexcode pro v5 and vexcode v5? I downloaded the vexcode v5 thinking it was the v5 text but it turns out to be text and blocks combined. Is the vexcode pro v5 the new v5 text version? I am not quite sure which one to download.

Yes.

“VEXcode V5 Blocks” was renamed to just “VEXcode V5” when support for basic text programming was added.

“VEXcode V5 Text” retains its more advanced functionality, and has been renamed to “VEXcode Pro V5”

3 Likes

That makes sense.
Thank you!!!

1 Like