Help with autonomous code

Im new to coding and Im trying to wrtie a method for driving forward but it only drive each wheel one at a time. I want it to drive both wheels at the same time. If someone could help me it would be greatly apperatiated.

void driveForward(double dis, double speed)
{
rightDriveMotor.spinFor(dis, rev, speed, vex::velocityUnits::pct);
leftDriveMotor.spinFor(dis, rev, speed, vex::velocityUnits::pct);
}

read the document about blocking and non-blocking function. It answers your question.

6 Likes

You might want to use a drive train. It is easy to setup and allows 2 motors for speed, but both wheels will move simultaneously. There is a tutorial you can watch. Good luck.

1 Like

This is API for the vex::drivetrain class and its usage example:

https://www.robotmesh.com/docs/vexv5-cpp/html/classvex_1_1drivetrain.html

2 Likes

This helped alot thank you

1 Like