Going off of a previous post... kinda...

So I’m having trouble and am getting a bit confused on how this all works. What I’m trying to do is if the potentiometer gets to a certain point (ex. the up most position) it can’t extend higher than it already is but it can go lower. But afterwards it would still be able to move up and down. Here’s the code.

int joystickvalue = joy1_y2;
//we'll pretend this is in a set task for now
while(true)
{
	if(((joystickvalue<0) && (SensorValue[PL]>=1050)) || ((joystickvalue>0) && (SensorValue[PL]<=250)))
	{
		motor[LL] = 0;
		motor[RL] = 0;
	}
	else if(((SensorValue[PL]<=1050) && (SensorValue[PL]>=250)) && (joystickvalue>0) || (joystickvalue<0))
	{
		motor[LL] = joystickvalue;
		motor[RL] = joystickvalue;
	}
}

Any assistance would be greatly appreciated, thank you!

in both cases, the condition is true if the sensor equals 1050 or 250. Try setting one to not equal.


int joystickvalue = joy1_y2;
//we'll pretend this is in a set task for now
while(true)
{
	if(((joystickvalue<0) && (SensorValue[PL]>=1050)) || ((joystickvalue>0) && (SensorValue[PL]<=250)))
	{
		motor[LL] = 0;
		motor[RL] = 0;
	}
	else if(((SensorValue[PL]<1050) && (SensorValue[PL]>250)) && (joystickvalue>0) || (joystickvalue<0))
	{
		motor[LL] = joystickvalue;
		motor[RL] = joystickvalue;
	}
}