@Ashton wrote
It looks like you are wanting to drive forward at maximum speed forever with the sensors keeping the drive motion straight. If that is your goal, you are not far off.
The main thing that will keep your code from working is the high likelihood (based on the way they are mounted on the bot) that one of the encoders will be generating negative numbers, and the other positive numbers. That being the case, you will promptly be stuck in the if test with the negative encoder less than the positive and drift that direction. You can avoid that error by testing for the absolute value rather than the raw value. For example:
if(abs(SensorValue[LeftEncoder]) > abs(SensorValue[RightEncoder]))
{
motor(leftwheels) = 100;
motor(rightwheels) = 127;
}
It is also important to know that motor power of 100 and 127 are not that different in most cases… The vex motors can reach their maximum speed at something like 90 in a low load situation. You would see a greater affect using 80 and 90 as your power values.
Lastly, if you want to drive straight for a set distance, you would change your while to check the value of one of the sensors versus a target, like this:
while (abs(SensorValue[LeftEncoder]) < 2500)
{
// your if statements
wait1msec(25) // don't hog cpu
}
motor(leftwheels) = 0;
motor(rightwheels) = 0;