How to make nxt robot go straight
Set the Motor Block Parameters to: Use a loop block to keep the program short. This is the part you write.
Select "Software" on the Robot. This is the detail window for the selected block. Use Swing turns to change direction. You may change the following variables: Drag a 2nd Motor Block to the Program Area.