Two arm motors controlled by one button

How to program v5 to operate two arm motors with one joystick button

One way to do this is with motor groups

motor_group armMotors(armMotor1, armMotor2);

Then you can just replace the motor with the motor group in the drive code.

2 Likes

I’m not a coder so forgive me if I’m wrong but wouldn’t that prevent you from reversing the direction of the motor? Assuming their motors are placed on opposite ends of the robot and are powering the same lift then one motor would require for its direction to be reversed.
Again, I’m not a coder so I may be wrong but you should be able to have the two motors move separately within a function on the same button. That way you can reverse the direction of one.
Also when you are coding I recommend testing one motor at a time so you dont accidentally twist and wreck your lift
(Im assuming by “arm motors” he was referring to a 4 bar lift though)

No, you can still reverse them. You need to create separate motor objects for each motor in the group anyways so you can just reverse it then.

motor armMotor1(PORT1, false);
motor armMotor2(PORT2, true);
motor_group armMotors(armMotor1, armMotor2);
1 Like

Ah that makes sense, sorry I don’t code. (I need to learn how to though if at least a just a little bit)

I assume you can configure motors the same way in VRC as in IQ, but I don’t do VRC. This is how you would configure a motor group with one motor reversed:

Click “Add a device”

Click “Motor Group”

Click whichever port one motor is in

And then whichever port the other one is in

And then click the forward-reverse toggle to reverse whichever one(s) you want. In IQ, you can even name the directions something other than “forward” and “reverse”.

3 Likes

You can reverse it in pro v5. It’s a little switch when you go into the motor. That way, any instance of that motor in the code you don’t have to worry about keeping track of forward and reverse.