Motor Progamming Text Problem

So I want to create a function which only needs two inputs, the speed of right and left motors. I just can’t figure out how can I move two individual motors at the same time? I am using the vexcode pro v5 for edr v5.Any help will be appreciated Thank you!

Program:
void go ( int speedleft, int speedright)
{
MotorL.spinFor (forward,speedleft,degrees); MotorR.spinFor (forward,speedright,degrees);
MotorL.spinFor (forward,speedleft,degrees); MotorR.spinFor (forward,speedright,degrees);
}
int main()
{
vexcodeInit();
go ( 90, 90 );
}
and for the program that I’ve programmed. the motor won’t be able to move at the same time

3 Likes

VEXCode? VEXCode Pro? VEXCode Python? Robotmesh? Pros? V5? VEX IQ?

Please give us context in order for us to help.

1 Like

I am using Vexcode Pro v5 for edr v5

So what’s happening here is called “Blocking code.” Basically, your program will stop at each spinFor command and until it is complete, it won’t move to the next line. Easy fix would be to just add false to the end like this:

void go ( int speedleft, int speedright){

MotorL.spinFor(forward,speedleft,degrees,false); 
MotorR.spinFor(forward,speedright,degrees,false);
MotorL.spinFor(forward,speedleft,degrees,false); 
MotorR.spinFor(forward,speedright,degrees);

}

int main(){

vexcodeInit();

go ( 90, 90 );

}

What this will do is it will tell the program to start the command then move on to the next line. Also, the reason for not having a false on the last line is so that it will stop on the last one and complete the movement before moving to the rest that you plan on doing.

11 Likes