
Re: Help understanding nMotorEncoderTarget[motor] command
According to the code you have posted, there is one instance of the nMotorEncoderTarget command (please correct me if I am wrong):
Generally, the nMotorEncoderTarget uses the following format:
The key lines are setting the encoder target, setting a power speed, and creating a while loop that keeps the motor power level the same until the target is reached and the nMotorRunState command returns a runStateIdle. We usually advise clearing the encoder counts to 0 before using the nMotorEncoderTarget command, unless you are keeping track of where you are at versus where you want to be (it appears in your code that you are doing so).
The best way to explain this is actually found in the linked Video Curriculum Trainer video; it goes over the three run states, the nMotorEncoderTarget command, and how to use them correctly in a program.
_________________Check out our
Blog! And our
Facebook page!
Need help? Take a look at our
updated help documentation and the
ROBOTC Forums.