Skip to content

DC motor — set speed/direction (dc_motor_speed)

What it does: Sets the speed of the selected DC motor; the sign of the value determines the direction of rotation.

dc_motor_speed

Inputs

  • Field motor_name: Engine ID (1 to 6).
  • in_speed: desired speed (typically -100 to 100).

Output

  • None (statement block).

When to use it

  • For starting, braking and changing the direction of the motor during the program.
  • In drive control according to sensors or joystick.

Tips and pitfalls

  • When using drives, also use a block to stop them when you press the STOP button in ESP IDE. Block: Execute this code on program exit
  • When changing direction quickly, add a short delay so that neither the driver nor the motor suffers.
  • Keep the speed within the recommended range of the library/driver used.

Usage example

example_dc_motor

Open example in ESP IDE

Generated Python example

dc_mot1.set_speed(60)