Driving a robot in a straight line using navX-Micro is very similar in nature to the Rotate to Angle example, the only difference being that the robot will move in a direction, and continually adjust the motors, just as in the Rotate to Angle example, to ensure that angular heading is maintained.
This example also includes the functionality to “reset” the “yaw” angle, so that the heading when forward motion starts is equivalent to zero degrees.
The PID Controller coefficients defined in the example code will need to be tuned for your drive system, and you may wish the adjust the update rate from the sensor to match the speed at which you wish to update the motors with new motor speeds.