VEX IQ "Teleop", how to move two motors for robot arm by operating one joystick


We can change the button or joystick action by “Teleop” program and I want to know how to create the below action;

if I switch the joystick to the horizontal direction, one motor(connected to ch10, for example) rotates,
and if I switch the same joystick to the vertical direction, another motor(connected to ch11, for example) rotates.

I know we can operate two Drive Motor(connected to ch1 and ch6) by operating one joystick.
(the code is “arcade control (chA, chB, 10)”, isn’t? )

And I want to move two more motors for arm part by operating another joystick.

Is this possible by “Teleop” program?

Please help me.

Thanks in advance for any assistance.

Are you using text or graphical ROBOTC? In graphical, just use the arcadeControl block.
If you are using text then something like:

setMotorSpeed(leftMotor, (getJoystickValue(ChA) + getJoystickValue(ChB));
setMotorSpeed(righttMotor, (getJoystickValue(ChA) - getJoystickValue(ChB));

For controlling 2 arm motors with a single joystick (make sure the inverts are set correctly under motor and sensor setup):

setMotorSpeed(armMotor1, (getJoystickValue(ChD));
setMotorSpeed(armMotor2, (getJoystickValue(ChD));

That is for using a joystick, not buttons for your arm control.

Thank you for your reply!

We use graphical ROBOTC and I try to do so:) !

@calvc01 's solution works, but that is not an ideal way to do it. Any time you’re reading a value and using it with the expectation that it’s the same, you should only read it once. Frequently it won’t matter, but there are times when it will, and those times will really bite you. Also, it’s faster to read a sensor only once and use the same value repeatedly instead of reading the sensor repeatedly. So a better way to write this would be:

int forwardDrive = 0;
int turnDrive = 0;
int armDrive = 0;

forwardDrive = getJoystickValue(ChA);
turnDrive = getJoystickValue(ChB);
setMotorSpeed(leftMotor, forwardDrive + turnDrive);
setMotorSpeed(righttMotor, forwardDrive - turnDrive);

armDrive = getJoystickValue(ChD);
setMotorSpeed(armMotor1, armDrive);
setMotorSpeed(armMotor2, armDrive);