
Re: Programming a motor to act like a servo
The trick with using an NXT motor as if it were a servo is to remember that you can't just tell it to go to a particular position. You can, however, tell it to go either forward or backwards until the encoder reaches a particular count. You also do not have any way of asking what position the motor is in at the start of your program. So, you will want to ensure that you move the motor by hand to a known starting position before starting your program. Let's say, as an example, that you want to call the starting position 0. That makes things easy. Just define a function like so: