Encoders Problem

Hello, I was programming an encoder to control my robot, but when I initialize forward, the robot will start going forward and won’t stop. I have the code that includes the encoder below

void forward(int pwr, int degs)
	SensorValue[LB] = 0;
	while (abs(SensorValue[LB]) <= degs)
		motor[RF] = pwr;
		motor[LF] = pwr;
		motor[RB] = pwr;
		motor[LB] = pwr;

Add this line into the while loop.

writeDebugStreamLine(" %d", SensorValue[LB]);

And then open the debug stream from robot->debugger->debug stream.

@tabor473 I tried that, but i’m not sure what its supposed to accomplish. Nothing appeared on the debug stream

I recently wrote a comprehensive post about all of the things that can cause encoders to go bad, which may be of use to you, now or sometime in the future: Why I’ll Never Use IMEs Again.