I am trying to find out how to move multiple motors at the same time for my auto program. Both motors (1 & 3) are needed to power the arm of the robot up and down. Any ideas?
Welcome to the forum! On the left side with all of the blocks, there is a “moveMultipleMotors” block. There is also a “stopMultipleMotors” block. I hope this helps!
To direct a motor to move, there are basically three steps:
1: Start the motor moving
2: Wait for some period of time, some amount of rotation, or some event to happen
3: Stop the motor from moving.
These three steps can either be programmed separately (3 lines of code), like this:
SetMultipleMotors (starts the selected motors running at some speed)
Wait (some amount of time)
StopMultipleMotors (turns off the selected motors)
Or a “canned function” like “move motor” can be used to execute all three lines of code in a single program step.
The limitation of canned function, as you have found, is that the line of code (for example line 9 above) must completely execute before the next line (line 10 above) can run, therefore the motors do not move at the same time.
In the example above, line 8 starts motors 1 and 3 running. Next, line 9 moves motor 3 a specific amount and stops it (while motor 1 is still running), then line 10 (if the arm hasn’t broken already) moves motor 1 a specific amount and stops it. Then line 11 moves all the motors assigned to the drivetrain a specific amount and stops them.
In your code, if motors 1 and 3 must work together, with one motor reversed, you’ll need to “reverse” one of the motors in your robot setup (click the check box) to match the physical setup. The setMultipleMotors command does not have the ability to move one motor one way and another motor the reverse.
Thank you so much!!!