Robot’s motors malfunction

Hello, my team and I just tested our code, and we found that the motors will spin in short, irregular bursts, rather than spinning constantly. We have narrowed down the problem to the code, but we can’t figure it out. I was wondering if anyone else has experienced this problem, and if they had a solution? Thanks

Are you using V5 or cortex?
What programming language are you using?
Can you post your code?

These will help people help you.

We are using a cortex and robotc. Here is a link to our code on github:
link text

@DaOctoOw Im no programming whiz, but I think the problem is that you are using multiple if loops, when you need to be using else if in some places. For example:

//intake controls:
if (vexRT[Btn7U] == 1){
motor[intake] = 127;
}
if (vexRT[Btn7D] == 1){
motor[intake] = -127;

}

In the bottom if loop you should be using an else if loop instead.

it should look something like this:

//intake controls:
if (vexRT[Btn7U] == 1){
motor[intake] = 127;
}
else if (vexRT[Btn7D] == 1){
motor[intake] = -127;

}else{

motor[intake] = 0;

}
(someone correct me if I am wrong)

You are correct. The code only has a single else statement that triggers when the catapult control is not pressed.


               //catapult code:
	        if (vexRT[Btn7R] == 1){
	         	motor[catapult] = 127;
	        }

		//if no buttons pressed, do nothing
		else{

you may want to move you startTask outside of the while loop

The task is being invoked each time the loop runs

@jpearman pls confirm, is it good practice to put small wait times in each infinite loop or task()?

Thanks, these things fixed the problem