Programming Help

I have only started programming in the last year, and I haven’t done too much advanced programming, and I have been running into a few problems, such as when using Btn8RXmtr2 the program has been working, however when using Btn7LXmtr2 that piece of programming doesn’t work and results in the arm jerking back and forth. Any help would be appreciated.

#pragma config(Sensor, in1, Arm, sensorPotentiometer)
#pragma config(Sensor, in2, Cone, sensorPotentiometer)
#pragma config(Sensor, dgtl1, DP12, sensorQuadEncoder)
#pragma config(Sensor, dgtl11, DP1112, sensorQuadEncoder)
#pragma config(Motor, port1, leftdriveback, tmotorVex393_HBridge, openLoop, driveLeft)
#pragma config(Motor, port2, leftdrivefront, tmotorVex393_MC29, openLoop, driveLeft)
#pragma config(Motor, port3, leftarm, tmotorVex393_MC29, openLoop, reversed)
#pragma config(Motor, port4, L1, tmotorVex393_MC29, openLoop)
#pragma config(Motor, port5, L2R2, tmotorVex393_MC29, openLoop)
#pragma config(Motor, port6, intake, tmotorVex393_MC29, openLoop)
#pragma config(Motor, port7, R1, tmotorVex393_MC29, openLoop, reversed)
#pragma config(Motor, port8, rightarm, tmotorVex393_MC29, openLoop)
#pragma config(Motor, port9, rightdrivefront, tmotorVex393_MC29, openLoop, reversed, driveRight)
#pragma config(Motor, port10, rightdriveback, tmotorVex393_HBridge, openLoop, reversed, driveRight)


task usercontrol()
{
// User control code here, inside the loop

while (true)
{

	if(vexRT[Btn5D] == 1) //Makes robot blow up
	{
		motor[rightdrivefront] = vexRT[Ch3] - vexRT[Ch4];
		motor[rightdriveback] = vexRT[Ch3] - vexRT[Ch4];
		motor[leftdrivefront] = vexRT[Ch3] + vexRT[Ch4];
		motor[leftdriveback] = vexRT[Ch3] + vexRT[Ch4];

		if(vexRT[Btn7U] == 1)
		{
			motor[rightarm] = 127;
		}
		else if(vexRT[Btn7D] == 1)
		{
			motor[rightarm] = -127;
		}
		else
		{
			motor[rightarm] = vexRT[Ch2];
		}

		if(vexRT[Btn8U] == 1)
		{
			motor[leftarm] = 127;
		}
		else if(vexRT[Btn8D] == 1)
		{
			motor[leftarm] = -127;
		}
		else
		{
			motor[leftarm] = vexRT[Ch2];
		}

		if(vexRT[Btn7LXmtr2] == 1)
		{
			 if(SensorValue[Cone] < 2680)
			{
				motor[L1] = 127;
				motor[R1] = 127;
				motor[intake] = 23;
			}
			else if(SensorValue[Cone] > 2680)
			{
				motor[L1] = -23;
				motor[R1] = -23;
				motor[intake] = 23;
				wait1Msec(800);
				motor[L1] = -23;
				motor[R1] = -23;
				motor[intake] = -127;
				wait1Msec(1000);
				motor[L1] = -127;
				motor[R1] = -127;
				motor[intake] = 0;
				wait1Msec(500);
				motor[L1] = 23;
				motor[R1] = 23;
				wait1Msec(500);
			}
		}
		else
		{
			motor[L1] = vexRT[Ch2Xmtr2];
			motor[R1] = vexRT[Ch2Xmtr2];
			motor[intake] = vexRT[Ch3Xmtr2];
		}

		if(vexRT[Btn8RXmtr2] == 1)
		{
			if(SensorValue[Arm] < 1000)
			{
				motor[L1] = 50;
				motor[R1] = 50;
				motor[intake] = 63;
				motor[leftarm] = -127;
				motor[rightarm] = -127;
			}
			else if(SensorValue[Cone] < 2680)
			{
				motor[L1] = 127;
				motor[R1] = 127;
				motor[intake] = 23;
				motor[leftarm] = -25;
				motor[rightarm] = -25;
			}
			else if(SensorValue[Cone] > 2680)
			{
				motor[L1] = -23;
				motor[R1] = -23;
				motor[leftarm] = -25;
				motor[rightarm] = -25;
				motor[intake] = 23;
				wait1Msec(800);
				motor[L1] = -23;
				motor[R1] = -23;
				motor[leftarm] = -25;
				motor[rightarm] = -25;
				motor[intake] = -127;
				wait1Msec(1000);
				motor[L1] = -127;
				motor[R1] = -127;
				motor[leftarm] = 0;
				motor[rightarm] = 0;
				motor[intake] = 0;
				wait1Msec(500);
				motor[L1] = 23;
				motor[R1] = 23;
				wait1Msec(500);
			}
		}
		else
		{
			motor[L1] = vexRT[Ch2Xmtr2];
			motor[R1] = vexRT[Ch2Xmtr2];
			motor[intake] = vexRT[Ch3Xmtr2];
			motor[leftarm] = vexRT[Ch2];
			motor[rightarm] = vexRT[Ch2];
		}


	}
	else
	{
		motor[rightdrivefront] = - vexRT[Ch3] - vexRT[Ch4];
		motor[rightdriveback] = - vexRT[Ch3] - vexRT[Ch4];
		motor[leftdrivefront] = - vexRT[Ch3] + vexRT[Ch4];
		motor[leftdriveback] = - vexRT[Ch3] + vexRT[Ch4];

		if(vexRT[Btn8U] == 1)
		{
			motor[rightarm] = 127;
		}
		else if(vexRT[Btn8D] == 1)
		{
			motor[rightarm] = -127;
		}
		else
		{
			motor[rightarm] = vexRT[Ch2];
		}

		if(vexRT[Btn7U] == 1)
		{
			motor[leftarm] = 127;
		}
		else if(vexRT[Btn7D] == 1)
		{
			motor[leftarm] = -127;
		}
		else
		{
			motor[leftarm] = vexRT[Ch2];
		}

		if(vexRT[Btn7LXmtr2] == 1)
		{
			 if(SensorValue[Cone] < 2680)
			{
				motor[L1] = 127;
				motor[R1] = 127;
				motor[intake] = 23;
			}
			else if(SensorValue[Cone] > 2680)
			{
				motor[L1] = -23;
				motor[R1] = -23;
				motor[intake] = 23;
				wait1Msec(800);
				motor[L1] = -23;
				motor[R1] = -23;
				motor[intake] = -127;
				wait1Msec(1000);
				motor[L1] = -127;
				motor[R1] = -127;
				motor[intake] = 0;
				wait1Msec(500);
				motor[L1] = 23;
				motor[R1] = 23;
				wait1Msec(500);
			}
		}
		else
		{
			motor[L1] = vexRT[Ch2Xmtr2];
			motor[R1] = vexRT[Ch2Xmtr2];
			motor[intake] = vexRT[Ch3Xmtr2];
		}

		if(vexRT[Btn8RXmtr2] == 1)
		{
			if(SensorValue[Arm] < 1000)
			{
				motor[L1] = 50;
				motor[R1] = 50;
				motor[intake] = 63;
				motor[leftarm] = -127;
				motor[rightarm] = -127;
			}
			else if(SensorValue[Cone] < 2680)
			{
				motor[L1] = 127;
				motor[R1] = 127;
				motor[intake] = 23;
				motor[leftarm] = -25;
				motor[rightarm] = -25;
			}
			else if(SensorValue[Cone] > 2680)
			{
				motor[L1] = -23;
				motor[R1] = -23;
				motor[leftarm] = -25;
				motor[rightarm] = -25;
				motor[intake] = 23;
				wait1Msec(800);
				motor[L1] = -23;
				motor[R1] = -23;
				motor[leftarm] = -25;
				motor[rightarm] = -25;
				motor[intake] = -127;
				wait1Msec(1000);
				motor[L1] = -127;
				motor[R1] = -127;
				motor[leftarm] = 0;
				motor[rightarm] = 0;
				motor[intake] = 0;
				wait1Msec(500);
				motor[L1] = 23;
				motor[R1] = 23;
				wait1Msec(500);
			}
		}
		else
		{
			motor[L1] = vexRT[Ch2Xmtr2];
			motor[R1] = vexRT[Ch2Xmtr2];
			motor[intake] = vexRT[Ch3Xmtr2];
			motor[leftarm] = vexRT[Ch2];
			motor[rightarm] = vexRT[Ch2];
		}
	}
}

}

I only have a moment to glance through that, but I’m surprised you don’t have a little more trouble. You have a few if, else if, else lines at the top which guarantee some value is being sent to some motors. Meanwhile, you have commands later to send values to the same motors. So now a motor is being given different values in an alternating fashion. It will try to keep switching between those values really quickly. That will cause the reaction you’re seeing. You need to make sure a given motor is only being assigned one value at a time.

Thank you, I think I understand what you mean, and I’ve been able to come up with this, which seems to work, if anyone still has any improvements, they would be much appreciated!

#pragma config(Sensor, in1, Arm, sensorPotentiometer)
#pragma config(Sensor, in2, Cone, sensorPotentiometer)
#pragma config(Sensor, dgtl1, DP12, sensorQuadEncoder)
#pragma config(Sensor, dgtl11, DP1112, sensorQuadEncoder)
#pragma config(Motor, port1, leftdriveback, tmotorVex393_HBridge, openLoop, driveLeft)
#pragma config(Motor, port2, leftdrivefront, tmotorVex393_MC29, openLoop, driveLeft)
#pragma config(Motor, port3, rightarm, tmotorVex393_MC29, openLoop, reversed)
#pragma config(Motor, port4, L1, tmotorVex393_MC29, openLoop)
#pragma config(Motor, port5, L2R2, tmotorVex393_MC29, openLoop)
#pragma config(Motor, port6, intake, tmotorVex393_MC29, openLoop)
#pragma config(Motor, port7, R1, tmotorVex393_MC29, openLoop, reversed)
#pragma config(Motor, port8, leftarm, tmotorVex393_MC29, openLoop)
#pragma config(Motor, port9, rightdrivefront, tmotorVex393_MC29, openLoop, reversed, driveRight)
#pragma config(Motor, port10, rightdriveback, tmotorVex393_HBridge, openLoop, reversed, driveRight)

task usercontrol()
{
// User control code here, inside the loop

while (true)
{

	if(vexRT[Btn5D] == 1) //Makes robot blow up
	{
		motor[rightdrivefront] = vexRT[Ch3] - vexRT[Ch4];
		motor[rightdriveback] = vexRT[Ch3] - vexRT[Ch4];
		motor[leftdrivefront] = vexRT[Ch3] + vexRT[Ch4];
		motor[leftdriveback] = vexRT[Ch3] + vexRT[Ch4];
	}
	else
	{
		motor[rightdrivefront] = - vexRT[Ch3] - vexRT[Ch4];
		motor[rightdriveback] = - vexRT[Ch3] - vexRT[Ch4];
		motor[leftdrivefront] = - vexRT[Ch3] + vexRT[Ch4];
		motor[leftdriveback] = - vexRT[Ch3] + vexRT[Ch4];
	}

	if(vexRT[Btn8U] == 1)
	{
		motor[rightarm] = -127;
	}
	else if(vexRT[Btn8D] == 1)
	{
		motor[rightarm] = 127;
	}
	else
	{
		motor[rightarm] = vexRT[Ch2];
	}

	if(vexRT[Btn7U] == 1)
	{
		motor[leftarm] = -127;
	}
	else if(vexRT[Btn7D] == 1)
	{
		motor[leftarm] = 127;
	}
	else
	{
		motor[leftarm] = vexRT[Ch2];
	}

	if(vexRT[Btn7LXmtr2] == 0 && vexRT[Btn8RXmtr2] == 0)
	{
		motor[L1] = vexRT[Ch2Xmtr2];
		motor[R1] = vexRT[Ch2Xmtr2];
		motor[intake] = vexRT[Ch3Xmtr2];
	}

	if(vexRT[Btn7LXmtr2] == 1 && SensorValue[Cone] < 1000)
	{
		motor[L1] = 127;
		motor[R1] = 127;
		motor[intake] = 63;
	}
	else if(vexRT[Btn7LXmtr2] == 1 && SensorValue[Cone] < 2750)
	{
		motor[L1] = 127;
		motor[R1] = 127;
		motor[intake] = 23;
	}
	else if(vexRT[Btn7LXmtr2] == 1 && SensorValue[Cone] > 2750)
	{
		motor[L1] = -23;
		motor[R1] = -23;
		motor[intake] = 23;
		wait1Msec(800);
		motor[L1] = -23;
		motor[R1] = -23;
		motor[intake] = -127;
		wait1Msec(1000);
		motor[L1] = -127;
		motor[R1] = -127;
		motor[intake] = 0;
		wait1Msec(500);
		motor[L1] = 23;
		motor[R1] = 23;
		wait1Msec(500);
		motor[L1] = 0;
		motor[R1] = 0;
		motor[intake] = 0;
		wait1Msec(100);
	}

	if(vexRT[Btn8RXmtr2] == 1 && SensorValue[Arm] < 1000)
	{
		motor[L1] = 50;
		motor[R1] = 50;
		motor[intake] = 63;
		motor[leftarm] = -127;
		motor[rightarm] = -127;
	}
	else if(vexRT[Btn8RXmtr2] == 1 && SensorValue[Cone] < 2850)
	{
		motor[L1] = 127;
		motor[R1] = 127;
		motor[intake] = 23;
		motor[leftarm] = -25;
		motor[rightarm] = -25;
	}
	else if(vexRT[Btn8RXmtr2] == 1 && SensorValue[Cone] > 2850)
	{
		motor[L1] = -23;
		motor[R1] = -23;
		motor[leftarm] = -25;
		motor[rightarm] = -25;
		motor[intake] = 23;
		wait1Msec(800);
		motor[L1] = -23;
		motor[R1] = -23;
		motor[leftarm] = -25;
		motor[rightarm] = -25;
		motor[intake] = -127;
		wait1Msec(1000);
		motor[L1] = -127;
		motor[R1] = -127;
		motor[leftarm] = 0;
		motor[rightarm] = 0;
		motor[intake] = 0;
		wait1Msec(500);
		motor[L1] = 23;
		motor[R1] = 23;
		wait1Msec(500);
		motor[L1] = 0;
		motor[R1] = 0;
		motor[leftarm] = 0;
		motor[rightarm] = 0;
		motor[intake] = 0;
		wait1Msec(100);
	}
}

}

Without getting through all your code, I have noticed you use loooong waits inside this single control loop. That means that while given part of code is executing, you have no control over the robot, no driving, no abort, no override.
To avoid this, you could split your control into multiple independent tasks - each task responsible for one subsystem and also handling its buttons - divide and conqueer.
As a side effect, your program would become easier to grasp and see the effects more localized…

I have to go with @nenik’s assessment of the buttons. When the partner joystick operator presses 7L or 8R and Sensor[cone] >2750 or 2850, respectively, absolutely no buttons on either joystick will do anything for the next 3 seconds, because it takes that amount of time to plow through the 7L / Sensor > 2750 (or 8R/Sensor >2850) section of code.

I wrote two brief articles this week, both of which are relevant to the code you posted here. The first is about a better way to structure button/joystick code, and the second is an introduction to RobotC tasks (mentioned by @nenik above).
https://renegaderobotics.org/set-motor-power-just/
https://renegaderobotics.org/robotc-tasks-the-basics/

Hope this helps.

You wrote that nicely. I’ve written several times on the forum about similar issues with multiple queries of the same sensor (as opposed to setting a single motor multiple times). The results are different, but the coding issue is pretty much the same.

I don’t quite understand how I could split that one else if command, however, I was wondering whether I was on the right track with this task program or whether I’m completely wrong as it is not working, and just making the robot jump.

Thanks!

#pragma config(Sensor, in1, Arm, sensorPotentiometer)
#pragma config(Sensor, in2, Cone, sensorPotentiometer)
#pragma config(Sensor, dgtl1, DP12, sensorQuadEncoder)
#pragma config(Sensor, dgtl11, DP1112, sensorQuadEncoder)
#pragma config(Motor, port1, leftdriveback, tmotorVex393_HBridge, openLoop, driveLeft)
#pragma config(Motor, port2, leftdrivefront, tmotorVex393_MC29, openLoop, driveLeft)
#pragma config(Motor, port3, rightarm, tmotorVex393_MC29, openLoop, reversed)
#pragma config(Motor, port4, L1, tmotorVex393_MC29, openLoop)
#pragma config(Motor, port5, L2R2, tmotorVex393_MC29, openLoop)
#pragma config(Motor, port6, intake, tmotorVex393_MC29, openLoop)
#pragma config(Motor, port7, R1, tmotorVex393_MC29, openLoop, reversed)
#pragma config(Motor, port8, leftarm, tmotorVex393_MC29, openLoop)
#pragma config(Motor, port9, rightdrivefront, tmotorVex393_MC29, openLoop, reversed, driveRight)
#pragma config(Motor, port10, rightdriveback, tmotorVex393_HBridge, openLoop, reversed, driveRight)

task normal()
{
while (true)
{
if(vexRT[Btn5D] == 1)
{
motor[rightdrivefront] = vexRT[Ch3] - vexRT[Ch4];
motor[rightdriveback] = vexRT[Ch3] - vexRT[Ch4];
motor[leftdrivefront] = vexRT[Ch3] + vexRT[Ch4];
motor[leftdriveback] = vexRT[Ch3] + vexRT[Ch4];
}
else
{
motor[rightdrivefront] = - vexRT[Ch3] - vexRT[Ch4];
motor[rightdriveback] = - vexRT[Ch3] - vexRT[Ch4];
motor[leftdrivefront] = - vexRT[Ch3] + vexRT[Ch4];
motor[leftdriveback] = - vexRT[Ch3] + vexRT[Ch4];
}

	motor[L1] = vexRT[Ch2Xmtr2];
	motor[R1] = vexRT[Ch2Xmtr2];
	motor[intake] = vexRT[Ch3Xmtr2];

	if(vexRT[Btn8U] == 1)
	{
		motor[rightarm] = -127;
	}
	else if(vexRT[Btn8D] == 1)
	{
		motor[rightarm] = 127;
	}
	else
	{
		motor[rightarm] = vexRT[Ch2];
	}

	if(vexRT[Btn7U] == 1)
	{
		motor[leftarm] = -127;
	}
	else if(vexRT[Btn7D] == 1)
	{
		motor[leftarm] = 127;
	}
	else
	{
		motor[leftarm] = vexRT[Ch2];
	}
}

}

task ground()
{
while (true)
{
if(SensorValue[Cone] < 1000)
{
motor[L1] = 127;
motor[R1] = 127;
motor[intake] = 63;
}
else if(SensorValue[Cone] < 2750)
{
motor[L1] = 127;
motor[R1] = 127;
motor[intake] = 23;
}
else if(SensorValue[Cone] > 2750)
{
motor[L1] = -23;
motor[R1] = -23;
motor[intake] = 23;
wait1Msec(800);
motor[L1] = -23;
motor[R1] = -23;
motor[intake] = -127;
wait1Msec(1000);
motor[L1] = -127;
motor[R1] = -127;
motor[intake] = 0;
wait1Msec(500);
motor[L1] = 23;
motor[R1] = 23;
wait1Msec(500);
motor[L1] = 0;
motor[R1] = 0;
motor[intake] = 0;
wait1Msec(100);
}
else
{
stopTask(ground);
}
wait1Msec(10);
}
}

task loader()
{
while (true)
{
if(SensorValue[Cone] > 2750)
{
motor[L1] = -127;
motor[R1] = -127;
motor[intake] = 63;
}
else if(SensorValue[Cone] < 2700)
{
motor[L1] = 23;
motor[R1] = 23;
motor[intake] = 23;
}
else if(SensorValue[Cone] < 2750 && SensorValue[Cone] > 2700 )
{
motor[L1] = -23;
motor[R1] = -23;
motor[intake] = 23;
wait1Msec(800);
motor[L1] = -23;
motor[R1] = -23;
motor[intake] = -127;
wait1Msec(1000);
motor[L1] = -127;
motor[R1] = -127;
motor[intake] = 0;
wait1Msec(500);
motor[L1] = 23;
motor[R1] = 23;
wait1Msec(500);
motor[L1] = 0;
motor[R1] = 0;
motor[intake] = 0;
wait1Msec(100);
}
else
{
stopTask(loader);
}
wait1Msec(10);
}
}

task groundmg()
{
while (true)
{
if(SensorValue[Arm] < 1000 && SensorValue[Cone] < 2850)
{
motor[L1] = 50;
motor[R1] = 50;
motor[intake] = 63;
motor[leftarm] = -127;
motor[rightarm] = -127;
}
else if(SensorValue[Cone] < 2850)
{
motor[L1] = 127;
motor[R1] = 127;
motor[intake] = 23;
motor[leftarm] = -20;
motor[rightarm] = -20;
}
else if(SensorValue[Cone] > 2850)
{
motor[L1] = -23;
motor[R1] = -23;
motor[leftarm] = -20;
motor[rightarm] = -20;
motor[intake] = 23;
wait1Msec(800);
motor[L1] = -23;
motor[R1] = -23;
motor[leftarm] = -20;
motor[rightarm] = -20;
motor[intake] = -127;
wait1Msec(1000);
motor[L1] = -127;
motor[R1] = -127;
motor[leftarm] = 0;
motor[rightarm] = 0;
motor[intake] = 0;
wait1Msec(500);
motor[L1] = 23;
motor[R1] = 23;
wait1Msec(500);
motor[L1] = 0;
motor[R1] = 0;
motor[leftarm] = 0;
motor[rightarm] = 0;
motor[intake] = 0;
wait1Msec(100);
}
else
{
stopTask(groundmg);
}
wait1Msec(10);
}
}

task loadermg()
{
while (true)
{
if(SensorValue[Arm] < 1000 && SensorValue[Cone] > 2800)
{
motor[L1] = -127;
motor[R1] = -127;
motor[intake] = 63;
motor[leftarm] = -127;
motor[rightarm] = -127;
}
else if(SensorValue[Cone] > 2800)
{
motor[L1] = -127;
motor[R1] = -127;
motor[intake] = 23;
motor[leftarm] = -20;
motor[rightarm] = -20;
}
else if(SensorValue[Cone] < 2750)
{
motor[L1] = 23;
motor[R1] = 23;
motor[intake] = 23;
}
else if(SensorValue[Cone] < 2800 && SensorValue[Cone] > 2750)
{
motor[L1] = -23;
motor[R1] = -23;
motor[leftarm] = -20;
motor[rightarm] = -20;
motor[intake] = 23;
wait1Msec(800);
motor[L1] = -23;
motor[R1] = -23;
motor[leftarm] = -20;
motor[rightarm] = -20;
motor[intake] = -127;
wait1Msec(1000);
motor[L1] = -127;
motor[R1] = -127;
motor[leftarm] = 0;
motor[rightarm] = 0;
motor[intake] = 0;
wait1Msec(500);
motor[L1] = 23;
motor[R1] = 23;
wait1Msec(500);
motor[L1] = 0;
motor[R1] = 0;
motor[leftarm] = 0;
motor[rightarm] = 0;
motor[intake] = 0;
wait1Msec(100);
}
else
{
stopTask(loadermg);
}
wait1Msec(10);
}
}

task usercontrol()
{
// User control code here, inside the loop

while (true)
{
	if(vexRT[Btn7LXmtr2] == 1)
	{
		startTask(ground);
	}
	else
	{
		startTask(normal);
	}

	if(vexRT[Btn7DXmtr2] == 1)
	{
		startTask(loader);
	}
	else
	{
		startTask(normal);
	}

	if(vexRT[Btn8RXmtr2] == 1)
	{
		startTask(groundmg);
	}
	else
	{
		startTask(normal);
	}

	if(vexRT[Btn8DXmtr2] == 1)
	{
		startTask(loadermg);
	}
	else
	{
		startTask(normal);
	}
}

}

It still looks like you’re assigning multiple values to some motors. That will always be problematic and result in jerky (literally, as jerk is the rate of change of acceleration, and you’re switching accelerations suddenly) behavior.

In the future, especially with so much code, could you use the code tags? Look just left of the quote tag in the reply menu bar. That makes the code much easier to read.

Also, you have a lot of lines of code with no comments. For comparison, a program (not robotics) I’ve been writing has on the order of a thousand lines of code. Most of those lines have little comments in them, and there are single-sentence or short-paragraph explanations for each function and the like, meaning I have about one and a half thousand lines of comments. That way I can go back and understand what I’ve done without having to commit it all to memory nor to have to figure it out again by reading the code.

Where are you referring to, that i am assigning multiple values? Thanks

All over the place. Look at task usercontrol(). Consider what happens if you hold down Btn7DXmtr2 and nothing else.

Your first if-then (Btn7LXmtr2) starts up task normal(). While that’s still running you also start up task loader() because Btn7DXmtr2 is true. Then the next two start of task normal() twice more.

I believe RobotC will kill the other normal() tasks when starting up normal() again, so you should be safe there instead of running piles of the same task. But you still have normal() and loader() running simultaneously. L1, R1, and intake are all being sent conflicting information by the two different tasks that are assigning values to them. It gets worse with other buttons, and it gets even worse if you hold down a few buttons at the same time.