Using vexcode v5 text how would I program two lines of code to work at once? For example if I want both sides of the intake to spin at the same time as it drives forward. Thank you guys sorry I’m a beginner programmer
Please, see this helpful post by jpearman about combining motors into groups:
Don’t be shy to ask if you have any questions.
Okay thank you! But that is for drivetrain, what if I were to want the intake to move at the same time as the wheels? I don’t think I would group the intake with the wheels, right?
I believe @weilin meant that you could make a group with the intakes. I will show some code that does not use motor groups.
Tell the intake to
intake.spin(forward,100,velocityUnits::pct);
intake2.spin(forward,100,velocityUnits::pct);
Then tell the drive to do whatever you need.
The spin command sets a motor spinning continuously. So the intakes will spin, while you are doing anything else. To stop the intakes use the stop command.
intake.stop(brakeType::brake);
intake2.stop(brakeType::brake);
You can use a different brake type.
You could easily implement motor groups with this, grouping the intakes together so that one command will apply to both (leave the drive out of it ). I’m sure you can figure it out
especially with the link from @weilin.
I think you probably need to use the startRotate functions, instead of just RotateTo and RotateFor.
Check out @thorstenl312 below.
The API (guide to all the commands in V5) is here - https://help.vexcodingstudio.com/
startRotate is a deprecated function. The more commonly used way is to use rotateTo/For and at the end, a false is added as the 5th parameter
If you want multiple things to run, you would need to use non-blocking functions. What this means is that you need to use functions that don’t wait for itself to end.
Some examples of blocking
Motor.rotateFor(1000, degrees, 100, percent);
Motor.rotateTo(1000, degrees, 100, percent);
wait(500, msec);
Some examples of non-blocking
Motor.rotateFor(1000, degrees, 100, percent, false);
Motor.rotateTo(1000, degrees, 100, percent, false);
Motor.spin()
As you can see, the false added to the end of rotateFor/rotateTo makes the function non-blocking