Drivetrain#

Introduction#

The VEX IQ (2nd generation) Drivetrain uses a built-in gyro sensor to support precise forward, reverse, and turning movements. These blocks allow the robot to move continuously or for set distances, rotate by degrees or to a heading, and respond to changes in its rotational orientation.

The drivetrain category also includes configuration blocks that let you set drive and turn speeds, define stopping behavior, apply timeouts to avoid execution stalls, and manually update the robot’s heading or rotation values. These features provide flexibility when designing autonomous behaviors or real-time adjustments.

A top-down view of a VEX IQ robot within a blue circular diagram showing cardinal directions. The robot is facing upward (0°). The diagram indicates 90° to the right, 180° at the bottom, and 270° to the left. The robot has orange and gray components, with "VEX3" visible on its front panel. Wheels are visible on both sides of the robot.

Below is a list of available blocks:

drive#

The drive block moves the drivetrain forward or in reverse using the current drive velocity. This block runs continuously until another Drivetrain block interrupts it or the project stops.

aria-description goes here#
  drive [forward v]

Parameters

Description

direction

The direction in which the robot drives, which can be one of the following:

  • forward
  • reverse

Example

aria-description goes here#
  when started :: hat events
  [Drive forward, then stop.]
  drive [forward v]    
  wait (2) seconds
  stop driving

drive for#

The drive for block moves the drivetrain forward or in reverse for a specified distance using the current drive velocity.

aria-description goes here#
  drive [forward v] for (200) [mm v] ▶

Parameters

Description

direction

The direction in which the robot drives, which can be one of the following:

  • forward
  • reverse

distance

The distance the robot drives, as an integer or decimal.

unit

The unit of measurement, which can be one of the following:

  • mm (millimeters)
  • inches

expanding arrow

By default, this is a waiting block, so the drivetrain will finish moving before running the next block. To make the drivetrain start moving and immediately run the next block right away, expand the block to say and don’t wait.

Example

aria-description goes here#
  when started :: hat events
  [Drive backward 500 mm.]
  drive [reverse v] for (500) [mm v] ▶

turn#

The turn block turns the drivetrain continuously left or right using the current turn velocity. The drivetrain will keep turning until another drivetrain block runs or the project stops.

aria-description goes here#
  turn [right v]

Parameters

Description

direction

The direction in which the robot turns, which can be one of the following:

  • left
  • right

Example

aria-description goes here#
  when started :: hat events
  [Turn right, then stop.]
  turn [right v]
  wait (2) seconds    
  stop driving

turn for#

The turn for block turns the drivetrain left or right for a specific number of degrees using the current turn velocity.

aria-description goes here#
  turn [right v] for (90) degrees ▶

Parameters

Description

direction

The direction in which the robot turns, which can be one of the following:

  • left
  • right

angle

The number of degrees the robot turns, as an integer or decimal.

expanding arrow

By default, this is a waiting block, so the drivetrain will finish turning before running the next block. To make the drivetrain start turning and immediately run the next block right away, expand the block to say and don’t wait.

Example

aria-description goes here#
  when started :: hat events
  [Turn left, then turn around to the right.]
  turn [left v] for (90) degrees ▶
  turn [right v] for (180) degrees ▶

turn to heading#

The turn to heading block turns the drivetrain to face a specific heading using the current turn velocity.

aria-description goes here#
  turn to heading (90) degrees ▶

Parameters

Description

heading

The absolute heading the drivetrain will turn to, from -360 to 360 degrees.

expanding arrow

By default, this is a waiting block, so the drivetrain will finish turning before running the next block. To make the drivetrain start turning and immediately run the next block right away, expand the block to say and don’t wait.

Example

aria-description goes here#
  when started :: hat events
  [Turn to face the cardinal directions.]
  turn to heading (90) degrees ▶
  wait (2) seconds
  turn to heading (180) degrees ▶
  wait (2) seconds
  turn to heading (270) degrees ▶
  wait (2) seconds
  turn to heading (0) degrees ▶
  wait (2) seconds

turn to rotation#

The turn to rotation block turns the drivetrain to face a specific rotational value using the current turn velocity.

A top-down view of a VEX IQ robot within a blue circular diagram showing rotational degrees. The robot is facing right (90°). The diagram indicates 0° at the top, 90° to the right, 180° at the bottom, 270° to the left, 360° at the top again, and 450° to the right with a blue arrow. The robot has gray and orange components, with "VEXIQ" visible on its side panel. Wheels are visible on both sides of the robot. A red arrow points from the robot towards the 90° mark.

aria-description goes here#
  turn to rotation (90) degrees ▶

Parameters

Description

rotation

The cumulative rotation value the robot will turn to, as an integer or decimal.

expanding arrow

By default, this is a waiting block, so the drivetrain will finish turning before running the next block. To make the drivetrain start turning and immediately run the next block right away, expand the block to say and don’t wait.

Example

aria-description goes here#
  when started :: hat events
  [Turn left, then spin in a circle clockwise and face right.]
  turn to rotation (-90) degrees ▶
  wait (2) seconds
  turn to rotation (450) degrees ▶

stop driving#

The stop driving block immediately stops all movement of the drivetrain.

aria-description goes here#
  stop driving

Parameters

Description

This block has no parameters.

Example

aria-description goes here#
  when started :: hat events
  [Drive forward, then stop.]
  drive [forward v]
  wait [4] seconds
  stop driving

set drive velocity#

The set drive velocity block sets the default movement speed as a percentage for all subsequent movement blocks in the project.

aria-description goes here#
  set drive velocity to (50) %

Parameters

Description

velocity

Sets the default movement velocity from 0 to 100 as a percent.

Example

  when started :: hat events
  [Drive forward at the default velocity.]
  drive [forward v] for (100) [mm v] ▶
  wait (1) seconds
  [Move slower.]
  set drive velocity to (20) %
  drive [forward v] for (100) [mm v] ▶
  wait (1) seconds
  [Move faster.]
  set drive velocity to (100) %
  drive [forward v] for (100) [mm v] ▶
  wait (1) seconds

set turn velocity#

The set turn velocity block sets the default velocity as a percent for all subsequent turn blocks in the project.

aria-description goes here#
  set turn velocity to (50) %

Parameters

Description

velocity

Sets the default turn velocity from 0 to 100 as a percent.

Example

  when started :: hat events
  [Turn around at default velocity.]
  turn [right v] for (100) degrees ▶
  wait (1) seconds
  [Turn around slower.]
  set turn velocity to (20) %
  turn [right v] for (100) degrees ▶
  wait (1) seconds
  [Turn around faster.]
  set turn velocity to (100) %
  turn [right v] for (100) degrees ▶
  wait (1) seconds

set drive stopping#

The set drive stopping block sets how the drivetrain behaves when drivetrain movement ends.

aria-description goes here#
  set drive stopping to [brake v]

Parameters

Description

stopping behavior

Sets how the drivetrain stops, which can be one of the following:

  • brake – Stops immediately.
  • coast – Slows gradually to a stop.
  • hold – Stops and resists movement using motor feedback.

Example

When started, sets stopping to coast, drives forward for 2 seconds, then stops.#
  when started :: hat events
  [Drive forward and coast to a stop.]
  set drive velocity to (100) %
  set drive stopping to [coast v]
  drive [forward v]
  wait (2) seconds
  stop driving

set drive timeout#

The set drive timeout block sets a time limit for how long a Drivetrain block will wait to reach its target. If the robot cannot complete the movement within the set time, it will stop automatically and continue with the next block.

Note: The Drivetrain’s time limit is used to prevent Drivetrain blocks that do not reach their target position from stopping the execution of other blocks in the stack.

aria-description goes here#
  set drive timeout to (1) seconds

Parameters

Description

time

The maximum number of seconds a Drivetrain block will run before stopping and moving to the next block.

Example

When started, limits drive time to 1 second and then turns 90 degrees.#
  when started :: hat events
  [Drive forward for 1 second, then turn.]
  set drive timeout to (1) seconds
  drive [forward v] for (25) [inches v] ▶
  turn [right v] for (90) degrees ▶

set drive heading#

The set drive heading block sets the gyro’s current heading to a specified value.

aria-description goes here#
  set drive heading to (0) degrees

Parameters

Description

heading

The heading value, in degrees, to assign to the gyro’s current orientation.

Example

aria-description goes here#
  when started :: hat events
  [Turn to the left.]
  set drive heading to (90) degrees
  turn to heading (0) degrees ▶

set drive rotation#

The set drive rotation block sets the gyro’s current cumulative rotation value.

aria-description goes here#
  set drive rotation to (0) degrees

Parameters

Description

rotation

The cumulative rotation value to assign, in degrees.

Example

aria-description goes here#
  when started :: hat events
  [Spin counterclockwise two times.]
  set drive rotation to (720) degrees
  turn to rotation (0) degrees ▶