pid code for driving robot in straight line

Hi,

I want my robot to go specific distance in a straight line and I came across this code.


http://www.robotc.net/wikiarchive/Tutorials/Arduino_Projects/Mobile_Robotics/VEX/Using_encoders_to_drive_straight

Has anyone tried this code verbatim? Is it reliable? Does it work?

Ya that looks just fine, not too different than what most people here do.

thanks, @tabor473 ! I too tried it just now and seems to work okay.

keep in mind that if you are using IMEs reference the encoder directly (SensorValue[encodername]) one side (typically right) will be reversed and encoder values will go the opposite direction. If you use nMotorEncoder[motorname] the reverse is accounted for.