Help with potentiometer code

what i’m trying to do is make it so depending what position I put my potentiometer is in, different motors will move. this is what I have so far:

[INDENT]#pragma config(Sensor,in1,pot,sensorPotentiometer)
task main(){
if(SensorValue[pot] < 255){
motor[port3] = 100;
wait1Msec(1000);
}else if(SensorValue[pot] < 550){
motor[port2] = 100;
wait1Msec(1000);
}else if(SensorValue[pot] < 787){
motor[port3] = -100;
wait1Msec(1000);
}else{
motor[port2] = -100;
wait1Msec(1000);
}
}
[/INDENT]

when I run the program, the robot will move motor[port2] backwards if the pot is in 3/4 of it’s range, and will move motor[port3] forward if it’s in another corner of the pot.

any help would be appreciated!

The range on the potentiometer is generally from 0 to ~4095 counts, over ~270 degrees of physical movement. This means that a small movement of just one degree will move the potentiometer ~15 counts. Try scaling the program for a larger range, if possible, to give your potentiometer a larger range to work with. This will increase the physical area that each ‘section’ of code will run in, and will help avoid the minimum/maximum issue that you are running into.