Motor functions

Hi, can anybody help me understand the difference between rotate for and using set rotation and reset rotation?

1 Like

First of all, you need to bookmark this very useful link to the online API reference for V5 motor functions:

Each V5 motor has a built-in encoder, that measures ticks when motor rotates. When you first turn on the power to the motor, internal counter of the encoder sets to zero. Then you can query the value of rotation counter either in degrees, rotations, or raw ticks.

When you call resetRotation() function it sets the value of internal counter to zero.

When you call setRotation(newValue) function it sets the counter to new value and you can specify the unit.

Then when you call rotateTo() function it will start spinning the motor until encoder counter value matches the argument you pass to the function.

If you call rotateFor() function it will take current counter value add the number of ticks/degrees/rotations that asked it to rotate and will spin the motor to get to that target.

You don’t have to reset the counter before calling rotateFor() function, because it rotates relative to the current position.


This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.