pxt-ev3/docs/reference/motors/motor/speed.md
Galen Nickel 88c58b4e76 First set of 'motors' topics (#305)
* Start of 'motors' topics

* Draft the 'motor motion' side doc

* Add / update more topics

* Last blast of edits

* Capture some more edits

* Put in movement and steering details
2018-02-06 19:43:50 -08:00

1.1 KiB

speed

Get the current speed of motor rotation as a percentage of maximum speed.

motors.largeA.speed()

The actual speed of the motor is the same or very close to it's current speed setting when the motor is regulated. If not regulated, the actual speed can change from the set speed when a force, or load, is applied to it.

Returns

  • a number which is the motor's current speed. This value is a percentage of maximum speed from 0 to 100. This number is negative, like -27, if the direction of rotation is in reverse.

Example

Turn speed regulation off and report the actual speed of the large motor in the forward direction. Occasionally touch the wheel on the motor to see if it changes the speed.

motors.largeA.setRegulated(false)
motors.largeA.setSpeed(55)
brick.showString("Actual speed:", 1)
for (let i = 0; i < 30; i++) {
    loops.pause(500)
    brick.showNumber(motors.largeA.speed(), 3)
}
motors.largeA.stop()

See also

tacho, speed, reset, clear counts