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!
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).
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:
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.
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.