pxt-ev3/docs/reference/motors/motor/speed.md
Galen Nickel 3a67190914
Add some 'infrared' api docs (#326)
* Add some 'infrared' api docs

* Fix display messages

* Change discussion of distance to relative

* Include motor speed note
2018-02-20 10:38:41 -08:00

1.2 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 speed you told it to run at (your desired or set point 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.run(55)
brick.showString("Actual speed:", 1)
for (let i = 0; i < 30; i++) {
    pause(500)
    brick.showNumber(motors.largeA.speed(), 3)
}
motors.largeA.stop()

See also

tacho, speed, reset, clear counts