DC motor — driver initialization (dc_motor_init)¶
What it does: Initializes an H-bridged DC motor using the dcmotorlib library on a pair of pins and sets the direction orientation.

Inputs¶
- Field
motor_name: Engine ID (1to6). - Field
direction of rotation: motor rotation direction (normal/reverse). pin1: first control pin.pin2: second control pin.
Output¶
- None (statement block).
When to use it¶
- Before first setting block speed
dc_motor_speed. - When configuring multiple motors with different pins.
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
- Control the DC motor via a suitable H‑bridge/driver, not directly from the GPIO.
- If the motor rotates in reverse, you can change
direction of rotationinstead of switching wires.
Usage example¶

Generated Python example¶
dc_mot1 = dcmotorlib.DCMotor(26, 27, 0)