Backward or Reverse?

Hi everyone!

I have a question about my code. I am making an if and else statement for certain buttons on my controller, but I don’t know whether to use backward or reverse for a certain motor.

     `if(Controller1.ButtonR2.pressing()) { //If button R2 is pressed...
            //...Spin the arm motor forward.
            ArmMotor1.spin(vex::directionType::fwd, armSpeedPCT, vex::velocityUnits::pct);
            ArmMotor2.spin(vex::directionType::**?**, armSpeedPCT, vex::velocityUnits::pct);
        }`

The question mark (?) is where I need to put the opposite direction. I’m thinking it should be reverse, but I don’t know what the abbreviation is. Can someone please tell me:

1-Whether I should use backward or reverse
2-What are the abbreviations for backward and reverse

Thanks! :grin:

P.S.- If I put in the drag and drop configuration that a certain motor is reversed, do I have to put reversed again or forward for that motor (in the code).

Pretty sure its rev, but I may be incorrect

1 Like

The docs are your friend! Per this page, the other possible value of vex::directionType is vex::directionType::rev.

If for some reason you want to use backwards (or any other value), you could do that by messing around with preprocessor directives:

#define vex::directionType::backwards vex::directionType::rev

but this is probably not a great idea from a readability/consistency standpoint.


Reversing the motor (through the drag-and-drop interface or a call to vex::motor.setReversed) will cause the motor to spin in the opposite direction when you pass vex::directionType::fwd to spin. For example, the following two code snippets will cause the motor to spin in the same direction:

//setReversed true, spin "forwards":
motorName.setReversed(true);
motorName.spin(vex::directionType::fwd);
//setReversed false, spin "backwards":
motorName.setReversed(false);
motorName.spin(vex::directionType::rev);

By reversing the default behavior of the motor, and changing what we tell the motor to do relative to its default behavior, we are essentially reversing the motor, then reversing it again, so the net effect is to spin in the same direction.

5 Likes

Thanks! It actually turned out to be rev :grinning:

Thanks so much! This comment was extremely helpful with my questions and other aspects about my code! :smiley:

I don’t know what you are planning to do for programming skills, autons ect, but it might be better to set up the motor as

motor ArmMotor2 = motor(PORTx, true);

the true at the end of the statement will always set the motor so that if you tell it to go reverse, it will go forwards and if you tell it to go reverse, it will go forwards.

Hope this helps you and good luck this season!

1 Like

I tried using rev like this:

RingLift.spin(rev, 100, pct);

But it doesn’t work. Please help