Smart Motor#

To make Smart Motor blocks appear in VEXcode V5, a Smart Motor must be configured in the Devices window.

For more information, refer to these articles:

Spin#

The Spin block is used to spin a motor or motor group forever, until a new Motion block is used or the program is stopped.

This is a non-waiting block and allows any subsequent blocks to execute without delay.

aria-description goes here#
  spin [Motor1 v] [forward v] 

Select which motor or motor group to use.

Diagram of a spin motor controller illustrating various motor control functions and settings for motion programming.

Select which direction for the motor or motor group to move in.

Diagram illustrating motor spin directions and control options for various motor blocks in a robotics programming context.

In this example, the motor will spin forward for 1 second before stopping.

aria-description goes here#
  when started :: hat events
  spin [Motor1 v] [forward v]     
  wait (1) seconds    
  stop [Motor1 v]

Spin For#

The Spin For block is used to spin a motor or motor group for a given distance.

This is can be a non-waiting or waiting block depending on if the and don’t wait option is used.

aria-description goes here#
  spin [Motor1 v] [forward v] for (90) [degrees v] ▶

Select which motor or motor group to use.

Diagram illustrating the Spin block for motor control in robotics, showcasing various motor commands and settings.

Select which direction for the motor or motor group to move in.

Diagram illustrating motor control options including spin, stop, and set parameters for various motor types.

Set how far the motor or motor group will spin by entering a value, and choosing the unit of measurement (degrees or turns).

Diagram illustrating various motor control blocks for spinning, stopping, and setting positions and velocities in robotics.

By default, the Spin for block will block any subsequent blocks from executing until it’s finished. By expanding the Spin for block to show and don’t wait, blocks will continue to execute while the motor or motor group is moving.

aria-description goes here#
  spin [Motor1 v] [forward v] for (1) [turns v] ◀ and don't wait

In this example, the motor will spin forward for 1 turn.

aria-description goes here#
  when started :: hat events
  spin [Motor1 v] [forward v] for (1) [turns v] ▶

Spin to Position#

The Spin to Position block is used to spin a motor or motor group to a set position.

This is can be a non-waiting or waiting block depending on if the and don’t wait option is used.

aria-description goes here#
  spin [Motor1 v] to position (90) [degrees v] ▶

Select which motor or motor group to use.

Diagram of a spin-to-position motor setup with control blocks for setting position, velocity, and stopping behavior.

Set how far the motor or motor group will spin by entering a value, and choosing the unit of measurement (degrees or turns).

Diagram illustrating the Spin to Position block for controlling motor movement to a specified angle in programming.

By default, the Spin to position block will block any subsequent blocks from executing until it’s finished. By expanding the Spin to position block to show and don’t wait, blocks will continue to execute while the motor is moving.

aria-description goes here#
  spin [Motor1 v] to position (90) [degrees v] ◀ and don't wait

In this example, the motor will spin to the 270 degrees position.

aria-description goes here#
  when started :: hat events
  spin [Motor1 v] to position (270) [degrees v] ▶

Stop Motor#

The Stop Motor block is used to stop the motor or motor group from moving.

This is a non-waiting block and allows any subsequent blocks to execute without delay.

aria-description goes here#
  stop [Motor1 v]

Select which motor or motor group to use.

Image of a stop motor block used in programming to halt motor movement in robotics applications.

In this example, the intake motors will spin in the intake direction for 1 second before stopping.

aria-description goes here#
  when started :: hat events
  spin [Motor1 v] [forward v]
  wait (1) seconds
  stop [Motor1 v]

Set Motor Position#

The Set Motor Position block is used to set a motor or motor group’s encoder position(s) to the entered value.

This is a non-waiting block and allows any subsequent blocks to execute without delay.

aria-description goes here#
  set [Motor1 v] position to (0) [degrees v]

Select which motor or motor group to use.

Diagram illustrating the Set Motor Position block for controlling motor encoder positions in programming.

Set the unit of measurement to use, degrees or turns.

Diagram illustrating motor position control blocks for smart motors in motion programming.

In this example, the motor’s encoder position is set to 90 degrees before the motor spins to the 0 degrees position.

aria-description goes here#
  when started :: hat events
  set [Motor1 v] position to (90) [degrees v]
  spin [MotorGroup2 v] to position (0) [degrees v] ▶

Set Motor Velocity#

The Set Motor velocity block is used to set the speed of a motor or motor group.

This is a non-waiting block and allows any subsequent blocks to execute without delay.

aria-description goes here#
  set [Motor1 v] velocity to (50) [% v]

Select which motor or motor group to use.

Diagram illustrating the Set Motor Velocity block for controlling motor speed in robotics programming.

The Set Motor velocity block will accept a range of -100% to 100%.

In this example, the motor will spin forward for 1 turn before setting the motor’s velocity to 75% before it spins in reverse for 1 turn.

aria-description goes here#
  when started :: hat events
  spin [Motor1 v] [forward v] for (1) [turns v] ▶
  set [Motor1 v] velocity to (75) [% v]
  spin [Motor1 v] [reverse v] for (1) [turns v] ▶

Set Motor Stopping#

The Set Motor Stopping block is used to set the behavior of the motor or motor group when they stop moving.

This is a non-waiting block and allows any subsequent blocks to execute without delay.

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

Select which motor or motor group to use.

Diagram illustrating the Set Motor Stopping block for controlling motor stopping behavior in robotics programming.

Select which stopping behavior to use.

The three drive stopping behaviors are as follows:

  • brake - The motor or motor group will come to an immediate stop.

  • coast - The motor or motor group will spin gradually to a stop.

  • hold - The motor or motor group will come to an immediate stop. If the motor or motor group is rotated by an outside force, the built-in encoder will move the motor or motor group back to its initial stopped position.

Diagram illustrating the Set Motor Stopping block options for controlling motor stopping behavior in robotics.

In this example, the motor moves for 2 seconds before coasting to a stop.

aria-description goes here#
  when started :: hat events
  [Set the motor's stopping mode to coast.]
  set [Motor1 v] stopping to [coast v]
  [Spin the motor forward for 2 seconds before stopping.]
  spin [Motor1 v] [forward v]   
  wait (2) seconds  
  stop [Motor1 v]

Set Motor Max Torque#

The Set Motor Max Torque block is used to set the strength of the V5 Smart Motor or motor group. This block accepts a range of 0% to 100%.

This is a non-waiting command and allows any subsequent commands to execute without delay.

aria-description goes here#
  set [Motor1 v] max torque to (50) %

Select which motor or motor group to use.

Diagram illustrating motor torque settings for smart motor control and programming options in robotics.

In this example, the motor’s torque is set to 80% before spinning to the 350 degree position.

aria-description goes here#
  when started :: hat events
  set [Motor1 v] max torque to (80) %    
  spin [Motor1 v] to position (350) [degrees v] ▶

Set Motor Timeout#

The Set Motor Timeout block is used to set a time limit for V5 Smart Motor or motor group’s movement blocks.

The motor or motor group’s time limit is used to prevent motion blocks that do not reach their position from preventing other blocks in the stack from running. An example of a motor or motor group not reaching its position is an arm or claw that reaches its mechanical limit and cannot complete its movement.

This is a non-waiting command and allows any subsequent commands to execute without delay.

aria-description goes here#
  set [Motor1 v] timeout to (1) seconds

Select which motor or motor group to use.

Image showing the Set Motor Timeout block for controlling motor movement limits in programming environments.

In this example, the motor is set to spin forward for 5 turns with a timeout of 1 second. The motor won’t reach the target position within 1 second, so the Spin block will automatically stop, and the motor will return to the 0 degrees position.

aria-description goes here#
  when started :: hat events
  [Set the motor's timeout to 1 second.]
  set [Motor1 v] timeout to (1) seconds
  spin [Motor1 v] [forward v] for (5) [turns v] ▶
  spin [Motor1 v] to position (0) [degrees v] ▶

Spin at Voltage#

The Spin at Voltage block is used to spin a V5 Smart Motor or Motor Group at a specified voltage.

This is a non-waiting command and allows any subsequent commands to execute without delay.

  spin [MotorGroup4 v] [forward v] at (10) volts

Select which motor or motor group to use.

Diagram illustrating the Spin at Voltage block for controlling motor speed and direction in robotics programming.

Select which direction for the motor or motor group to move in.

Diagram illustrating the Spin at Voltage block for controlling motor direction and voltage settings in robotics programming.

The Spin at Voltage block accepts a range from -10V to 10V.

In this example, MotorGroup4 will spin forward at 4 volts for 2 seconds before stopping.

  when started :: hat events
  spin [MotorGroup4 v] [forward v] at (4) volts
  wait (2) seconds
  stop [MotorGroup4 v]