Help With Some Code

I am working on the auton selector which is 2 limit switches that are held down with zip ties, one for color, and one for position. When I compile it in robotC it says “Mismatched typedefs. Converting typedef ‘char’ to typedef ‘tSensors’, value ‘leftpot’” What does this mean? Here is the code…

task autonomous()
{
	if  (SensorValue(autonleftright)== 1 && SensorValue(autoncolor == 1))//blue right
	{
		while (SensorValue(chassisleft) < 313.6)
		{
		motor[port2]  = -127;
		motor[port4] =  -127;
		motor[port7] = -127;
		motor[port9 ] = -127;
	}
	motor[Launcher1]=127;
	motor[Launcher2]=127;
	wait1Msec (100);
	motor[Launcher1]=-127;
	motor[Launcher2]=-127;
	wait1Msec (100);
}
} 

I believe your problem is right here:

You have the “==1” inside the parentheses for checking SensorValue. Thus, you’re getting a type mismatch, because autoncolor cannot be compared to 1. If you take it out like you had done with autonleftright it should work.

I hope that helps :slight_smile:

That fixed it. Thank you.

Also the SensorValue should be referenced as an array using Square parenthesis
Like so:


SensorValue[port]

As SensorValue is an array of values

I think that it works with parentheses, though I have no idea why. I always use brackets, but parentheses don’t seem to throw an error.