Robot Specific Blocks#

All standard VEXcode VR Blocks are available for use in the GO Competition - Mars Math Expedition Playground.

Motion#

This Playground’s Blocks will have access to the ArmMotor parameter for all Motion blocks.

Spin#

The Spin block is used to spin a motor indefinitely.

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

    spin [ArmMotor v] [up v]

Select which direction for the motor to move in.

Image illustrating the Spin block for motor control in VEXcode VR, demonstrating motor direction and operation.

In this example, the Arm Motor will spin in the Up direction for 1 second before stopping.

    when started
    [Spin the Arm Motor up indefinitely.]
    spin [ArmMotor v] [up v]
    [Wait 1 second.]
    wait (1) seconds
    [Stop the Arm Motor from moving.]
    stop [ArmMotor v]

Spin for#

The Spin for block is used to spin a motor 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.

  spin [ArmMotor v] [up v] for [90] [degrees v] ▶

Select which direction for the motor to move in.

Image depicting the VEXcode VR Spin block used to control motor direction and movement duration in programming.

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

Image showing the VEXcode VR Spin for block used to control motor movement in the Mars Math Expedition Playground.

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 is moving.

  spin [ArmMotor v] [up v] for [90] [degrees v] ◀ and don't wait

In this example, the Arm Motor will spin in the Up for 200 degrees.

  when started
  [Sping Arm Motor Up for 200 degrees.]
  spin [ArmMotor v] [up v] for [200] [degrees v] ▶

Spin to position#

The Spin to position block is used to spin a motor 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.

  spin [ArmMotor v] to position [90] [degrees v] ▶

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

Image of VEXcode VR Spin to Position block, illustrating motor control for precise movement in robotics 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.

  spin [ArmMotor v] to position [90] [degrees v] ◀ and don't wait

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

  when started
  spin [ArmMotor v] to position [180] [degrees v] ▶

Stop Motor#

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

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

  stop [ArmMotor v]

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

  when started
  [Spin the Arm Motor up indefinitely.]
  spin [ArmMotor v] [up v]
  [Wait 1 second.]
  wait (1) seconds
  [Stop the Arm Motor from moving.]
  stop [ArmMotor v]

Set Motor position#

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

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

  set [ArmMotor v] position to [0] [degrees v]

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

Illustration of VEXcode VR Motor Position Unit used in robot programming for motion control and motor position settings.

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

  when started
  [Set Arm Motor position to 90 degrees.]
  set [ArmMotor v] position to [90] [degrees v]
  [Spin Arm Motor to 0 degrees.]
  spin [ArmMotor v] to position [0] [degrees v] ▶

Set Motor velocity#

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

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

  set [ArmMotor v] velocity to [50] [% v]

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

In this example, the Motor’s velocity is set to 75% before it spins for 1 turn in the intake direction.

  when started
  [Set Arm Motor velocity to 100%.]
  set [ArmMotor v] velocity to [100] [% v]
  [Spin Arm Motor Up for 1 turn.]
  spin [ArmMotor v] [up v] for [1] [turns v] ▶

Set Motor timeout#

The Set Motor timeout block is used to set a time limit for Motor movement blocks.

This prevents motion blocks that do not reach their intended position from preventing subsequent blocks from running.

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

  set [ArmMotor v] timeout to [1] seconds

In this example, the motor timeout is set to 2 seconds before it spins the motor for 3 turns in the outtake direction.

  when started
  [Set Arm Motor timeout to 1 second.]
  set [ArmMotor v] timeout to [1] seconds
  [Spin Arm Motor Up for 3 turn.]
  spin [ArmMotor v] [up v] for [3] [turns v] ▶

Sensing#

The virtual Hero Robot has access to the standard Brain and Drivetrain Sensing Blocks.

Motor Sensing#

Motor is done#

The Motor is done block is used to report if the selected Motor or Motor Group has completed its movement.

  <[ArmMotor v] is done?>

The Motor is done block reports True when the selected Motor or Motor Group has completed its movement.

The Motor is done block reports False when the selected Motor or Motor Group has not completed its movement.

The Motor is done block is used in blocks with hexagonal (six-sided) spaces.

Example coming soon.

Motor is spinning#

The Motor is spinning block is used to report if the selected Motor or Motor Group is moving.

  <[ArmMotor v] is spinning?>

The Motor is spinning block reports True when the selected Motor or Motor Group is moving.

The Motor is spinning block reports False when the selected Motor or Motor Group is not moving.

The Motor is spinning block is used in blocks with hexagonal (six-sided) spaces.

Example coming soon.

Position of motor#

The Position of motor block is used to report the position of a Motor or the first motor in a Motor Group.

  ([ArmMotor v] position in [degrees v])

Select when unit to use, degrees or turns.

Illustration of VEXcode VR Motor Position Unit used in robot programming for motion control and motor position settings.

The Position of motor block is used in blocks with circular spaces.

In this example, the robot will print the current position of the Arm Motor.

  when started
  print ([ArmMotor v] position in [degrees v]) ▶

Velocity of motor#

The Velocity of motor block is used to report the current velocity of a Motor or the first motor in a Motor Group.

  ([ArmMotor v] velocity in [% v] :: custom-motion)

The Velocity of motor block is used in blocks with circular spaces.

In this example, the robot will print the current velocity of the Arm Motor.

  when started
  print ([ArmMotor v] velocity in [% v] :: custom-motion) ▶

Eye Sensing#

Found object#

The Found object block is used to report if the Front Eye Sensor detects an object within approximately 40 millimeters (mm) or 1.5 inches.

  <[FrontEye v] found an object?>

The Found object block reports True when the Front Eye Sensor detects an object within approximately 40 millimeters (mm) or 1.5 inches.

The Found object block reports False when an object is not within approximately 40 millimeters (mm) or 1.5 inches.

The Found object block is used in blocks with hexagonal (six-sided) spaces.

In this example, the robot will check if its Front Eye Sensor has detected an object and print if it has or hasn’t detected anything.

  when started
  if <[FrontEye v] found an object?> then
  print [Object detected!] ▶
  end
  print [No object detected.] ▶

Detects color#

The Detects color block is used to report if the Front Eye Sensor detects the specified color of an object.

  <[FrontEye v] detects [red v]?>

Select which color to detect.

detects_color_color

The Detects color block reports True when the Eye Sensor detects the specified color of an object.

The Detects color block reports False when the Eye Sensor does not detect the specified color of an object.

The Detects color block is used in blocks with hexagonal (six-sided) spaces.

In this example, the robot will check if its Front Eye Sensor has detected a Blue object and print if it has detected one.

  when started
  if <[FrontEye v] detects [blue v]?> then
  print [Blue object detected.] ▶
  end

Brightness of#

The Brightness of block is used to report the brightness of the object detected by the Eye Sensor.

  ([FrontEye v] brightness in %)

The Brightness of block is used in blocks with circular spaces.

In this example, the robot will print the current brightness of an object. Since there is no object in front of the sensor, it will print a 0.

  when started
  print ([FrontEye v] brightness in %) ▶

Hue of#

The Hue of block is used to report the hue value of the color detected by the Eye Sensor.

  ([FrontEye v] hue in degrees)

The Hue of block provides a hue value between 0 to 359 degrees. This provides a more precise measurement of color.

color_wheel

The Hue of block is used in blocks with circular spaces.

In this example, the robot will print the current hue of an object. Since there is no object in front of the sensor, it will print a 0.

  when started
  print ([FrontEye v] hue in degrees) ▶

Gyro Sensing#

Detected crash?#

The Detected crash? block is used to report if the robot has come in contact with a wall or other object.

  <detected crash?>

The Detected crash? block reports True if the robot comes in contact with a wall or other object.

The Detected crash? block reports False if the robot does NOT come in contact with a wall or other object.

The Detected crash? block is used in blocks with hexagonal (six-sided) spaces.

In this example, the robot will drive forward until it has crashed, then it will stop moving.

  when started
  [Drive forward indefinitely]
  drive [forward v]
  [Wait until the robot has driven into something.]
  wait until <detected crash?>
  [Stop driving.]
  stop driving