How to make two lines of code work at one time?

Hello, I’m attempting to code the RI3D robot for this year’s game “Tower Takeover.” However, I am unsure of how to make two lines of code work at one time since usually it runs one command after the other. I tried using a while(true) command but it made it go in a loop, not at the same time. Also, I’m using motor groups.

Simply, set one group to spin, then set the other group to spin but tell it to wait.

group1.rotateTo(500,deg,75,velocityType::pct,false);
group2.rotateTo(500,deg,75,velocityType::pct,true);

This is the simplest way to do it. There are however many others that would work.

3 Likes

Does the pct, false and pct, true part make it wait?

Yes the last argument is a boolean on whether the command should wait until completion.

3 Likes

Right before it, you could use Motor.spin to get the rollers to spin

That just creates an instance of a drivetrain called robotDrive, it will not cause the robot to move. It’s also really big, you have 35 inch wheel travel (so 11 inch diameter wheels).

3 Likes