I know there’s a way to reduce the amount of lines of code regarding motor commands. Our robot has 4 chassis motors that repeatedly move the robot forward and backward with all 4 motors turning in the same direction at the same speed. I believe there is a way to reduce the 4 lines of code that direct each motor individually to only one line of code. How do we do that?
thanks
It looks like this was already answered here.
https://vexforum.com/t/ktor-wants-to-help-you-and-help-us/18289/1
but here’s an example.
void
setMotors( int speed ) {
motor port1 ] = speed;
motor port2 ] = speed;
motor port3 ] = speed;
motor port4 ] = speed;
}
task main()
{
// Using a function
setMotors( 100 );
wait1Msec(1000);
setMotors( 0 );
// or all on one line
motor port1 ] = motor port2 ] = motor port3 ] = motor port4 ] = 100;
}
1 Like