nMotorEncoder[motorA] = 0; // reset
nMotorEncoderTarget[motorA]=1000; //where you want to move to
motor[motorA] = 100; //move at full speed
while (nMotorRunState[motorA] != runStateIdle)
//nxtDisplayTextLine(2,"Enc A=%d", nMotorEncoder[motorA]);
When using a motor target, the motor goes through different stages of power output. Ramping up, ramping down, idle, steady state, and holding encoder value.
When in idle, the motor is not moving anymore so it is on or very close to the target.
If you want to read more on these commands, double click on Motors in the Code Templates tool bar and it will bring up descriptions and brief explanations of the different motor commands.
The encoder target works nicely with low motor strain applications, otherwise you have to take a different approach. If you are interested, check out this forum topic too.
Good Luck B-)