Double-Checking Code

Hi, I’m going to download this code into my robot tomorrow for the minefield challenge. I just want to make sure everything will run as planned and make sure there aren’t any flaws in my code.

(I’m a beginner btw)

#pragma config(Motor, port2, rightMotor, tmotorServoContinuousRotation, openLoop, reversed)
#pragma config(Motor, port3, leftMotor, tmotorServoContinuousRotation, openLoop)
#pragma config(Motor, port4, armMotor, tmotorServoContinuousRotation, openLoop)
#pragma config(Motor, port9, armMotorB, tmotorServoContinuousRotation, openLoop, reversed)
//!!Code automatically generated by ‘ROBOTC’ configuration wizard !!//

task main()
{

// Autonomous Code
while(vexRT[Btn7U] == 0) // while button 7U is not pressed
{												 // do nothing until button 7U is pressed
}

clearTimer(T2);
while(time1[T2] < 30000)
{
	wait1Msec(3000);

	motor[rightMotor] = -127; // backwards
	motor[leftMotor] = -127;
	wait1Msec(1500);

	motor[rightMotor] = 0; //stop
	motor[leftMotor] = 0;
	motor[armMotor] = 40; //arm up
	motor[armMotorB] = 40;
	wait1Msec(1250);

	motor[armMotor] = -40; // arm down
	motor[armMotor] = -40;
	wait1Msec(1250);

	motor[rightMotor] = 127; // forward
	motor[leftMotor] = 127;
	wait1Msec(1500);
}



// Remote Control Code
while(vexRT[Btn7D] == 0) // while button 7D is not pressed...
{												 // do nothing until button 7d is pressed
}

clearTimer(T1);
while(time1[T1] < 90000)
		{

			motor[leftMotor] = vexRT[Ch3] / 2;
			motor[rightMotor] = vexRT[Ch2] / 2;

			// Arm Control Code
			if(vexRT[Btn6U]  == 1)
			{
				motor[armMotor] = 50;
				motor[armMotorB] = 50;

			}
			else if(vexRT[Btn6D] == 1)
			{
				motor[armMotor] = -50;
				motor[armMotorB] = -50;

			}
			else
			{
				motor[armMotor] = 0;
				motor[armMotorB] = 0;
			}

		}

motor[leftMotor] = 0;
motor[rightMotor] = 0;

}

You should really test code on a cortex/brain/whatever. And also, it would be helpful if you properly escaped the code, by putting 3 grave ticks (`) above the code and 3 below. But compiling and running is always going to be better than the opinions of forum users.

Also, judging by the code, you aren’t using V5. That appears to be RobotC, which was used on Cortex, not V5.

3 Likes

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.