I am using a four motor base for my robot
How do I assign the two right motors to one variable.
I am using a four motor base for my robot
How do I assign the two right motors to one variable.
Make a function:
#include "robot-config.h"
void controlTwoMotors(int speed) {
FirstMotor.spin(vex::directionType::fwd, speed, vex::velocityUnits::pct);
SecondMotor.spin(vex::directionType::fwd, speed, vex::velocityUnits::pct);
}
int main() {
while(true) {
controlTwoMotors(Controller1.Axis3.value());
vex::task::sleep(20);
}
}
Thank you
I will try it.
Make a function:
#include "robot-config.h"
void controlTwoMotors(int speed) {
FirstMotor.spin(vex::directionType::fwd, speed, vex::velocityUnits::pct);
SecondMotor.spin(vex::directionType::fwd, speed, vex::velocityUnits::pct);
}
int main() {
while(true) {
controlTwoMotors(Controller1.Axis3.value());
vex::task::sleep(20);
}
}
[/quote]
How can I use this in a rotateFor command?
Just use rotateFor instead of spin in the function:
void twoLeftMotorsRotateFor (arguments as appropriate) {
motor1.startRotateFor( info either constants or from arguments );
motor2.rotateFor( info either constants or from arguments );
}
There are a lot of other embellishments that can be accomplished by this kind of separating things out into functions, to the point where the top-level calls look incredibly simple, but with lots going on under the hood.