DC Motor(直流马达)

此类专用于 EV3 和 NXT,可让你驱动无法被自动识别为马达的马达,包括通过官方转换线连接的 RCX 马达和 Power Function 马达。注意:对自定义电子设备施加马达电源可能会损坏主控或设备。

For Powered Up DC Motors, just use the DCMotor(直流马达) class instead, which will automatically detect the motor and use the correct and safe settings.

../_images/iodevice-dcmotor.png
class DCMotor(port, positive_direction=Direction.CLOCKWISE)

LEGO® MINDSTORMS EV3 直流马达。

参数:
  • port (Port) – 马达所连接的端口。

  • positive_direction (方向) – 给定正占空比值时马达应转动的方向。

dc(duty)

以给定的占空比(也称为“功率”)旋转马达。

参数:

duty (Number, %) – 占空比(-100.0 到 100)。

brake()

被动制动马达。

马达会因摩擦以及马达仍在转动时产生的电压而停止。

stop()

停止马达并让其自由旋转。

马达会因摩擦而逐渐停止。

settings(max_voltage)
settings() → tuple[int]

配置马达设置。如果不给参数,则返回当前值。

参数:

max_voltage (Number, mV) – 在所有马达命令中施加到马达上的最大电压。