Skip to main content

Motion

Servo motor

A servo motor rotates to precise angles, making it perfect for controlling the movement of robotic arms, legs, or other mechanical parts. Servo motors are controlled by sending a pulse width modulated (PWM) signal to the motor. The length of the pulse determines the angle of the servo motor.

tip

Make sure to attach the servo motor before using other servo motor blocks.

Attach servo motor

The attach servo block sets up a servo motor on a specific pin.

  • servo: The servo motor to attach. This is stored as a variable.
  • pin: The pin to attach the servo motor to.

The attach servo block must be used before any other servo motor blocks.

Attach servo motor (advanced)

The advanced attach servo block sets up a servo motor on a specific pin with a custom pulse width range.

  • servo: The servo motor to attach. This is stored as a variable.
  • pin: The pin to attach the servo motor to.
  • min: The minimum pulse width in microseconds.
  • max: The maximum pulse width in microseconds.

The attach servo block must be used before any other servo motor blocks. You can use this block instead of the basic attach servo block if you need to customise the pulse width range.

Detach servo motor

The detach servo block stops the selected servo motor from moving and frees up the pin it was attached to.

Set servo motor angle

The set servo angle block rotates the servo motor to a specific angle.

  • servo: The servo motor to move.
  • angle: The angle to move the servo motor to. (0-180 degrees)

Read servo motor angle

The read servo angle block gets the current angle of the servo motor.

Stepper motor

A stepper motor rotates in exact steps. Each step is a fixed angle, and the motor can rotate a precise number of steps in either direction. Stepper motors are controlled by sending a sequence of pulses to the motor. The number of pulses determines the number of steps the motor rotates.

tip

Make sure to attach the stepper motor before using other stepper motor blocks.

Attach stepper motor (2 pins)

The attach stepper block sets up a stepper motor on two specific pins.

  • stepper: The stepper motor to attach. This is stored as a variable.
  • steps: The number of steps per revolution of the stepper motor.
  • pins 1-2: The two pins to attach the stepper motor to.

Attach stepper motor (4 pins)

The attach stepper block sets up a stepper motor on four specific pins.

  • stepper: The stepper motor to attach. This is stored as a variable.
  • steps: The number of steps per revolution of the stepper motor.
  • pins 1-4: The four pins to attach the stepper motor to.

Set stepper motor speed

The set stepper speed block sets the speed of the stepper motor. The speed is measured in revolutions per minute (RPM).

  • stepper: The stepper motor to set the speed of.
  • speed: The speed of the stepper motor in revolutions per minute (RPM).

Step stepper motor

The step stepper block rotates the stepper motor a specific number of steps.

  • stepper: The stepper motor to move.
  • steps: The number of steps to move the stepper motor. Positive values rotate the motor clockwise, and negative values rotate the motor anti-clockwise.

DC motor (L298N)

A DC motor is a simple motor that rotates when a voltage is applied to it. The L298N is a motor driver that can control the speed and direction of two DC motors. The L298N motor driver is commonly used in robotics projects to control the movement of wheeled robots.

tip

Make sure to attach the DC motor before using other DC motor blocks.

Attach DC motor

The attach DC motor block sets up an L298N motor driver to control two DC motors.

  • motor driver: The motor driver to attach. This is stored as a variable.
  • enA: The pin connected to the enable A input of the motor driver.
  • enB: The pin connected to the enable B input of the motor driver.
  • in1-in4: The four pins connected to the input pins of the motor driver.

Set DC motor direction

The set DC motor direction block sets the direction of the DC motor.

  • motor driver: The motor driver to control.
  • motor: The motor to set the direction of. (A or B)
  • direction: The direction of the motor. (forward, reverse, or stop)

Set DC motor speed

The set DC motor speed block sets the speed of the DC motor. The speed is measured in percentage of the maximum speed.

  • motor driver: The motor driver to control.
  • motor: The motor to set the speed of. (A or B)
  • speed: The speed of the motor as a percentage. (0-100%)