Robot-Specific Blocks#
Introduction#
The VIQRC 22-23 Slapshot Playground features blocks exclusive to this Playground, including two motor options and the Optical Sensor.
All standard VEXcode VR Blocks are available for use in the VIQRC 22-23 Slapshot Playground.
Below is a list of all available Playground-specific Blocks:
Motion - Move and track the robot’s motors.
Actions
spin motor - Spins the selected motor indefinitely.
spin motor for - Spins a motor for a specific distance in degrees or turns.
spin motor to position - Spins a motor to a set position.
stop motor - Stops a specific motor from spinning.
Settings
set motor velocity - Sets the speed of a motor as a percentage.
set motor timeout - Limits how long a motor block waits before giving up if movement is blocked.
Position
motor position - Returns the motor’s current rotational position in degrees or turns.
set motor position - Sets the encoder value of a motor.
Values
motor is done? - Returns a Boolean indicating whether the motor is no longer spinning.
motor is spinning? - Returns a Boolean indicating whether the motor is currently spinning.
motor velocity - Returns the motor’s current velocity in %.
Sensing - Utilize the robot’s various sensors.
Optical
Optical found an object? - Returns whether an object is detected.
Optical detects color? - Returns whether a specific color is detected.
Optical brightness - Returns the brightness percentage detected by the sensor.
Optical hue - Returns the hue value of the detected color.
when Optical - Executes the attached stack of blocks when the Optical Sensor detects or loses an object.
The examples on this page use the default Playground start position.
Motion#
Actions#
spin motor#
The spin motor block spins a selected motor in a specified direction using the current motor velocity.
spin [IntakeMotor v] [intake v]
Parameters |
Description |
|---|---|
motor |
The motor to spin:
|
direction |
The direction to spin:
|
Example
cuando empezó
[Spin the Intake Motor before stopping.]
spin [IntakeMotor v] [intake v]
esperar (1) segundos
stop [IntakeMotor v]
spin motor for#
The spin motor for block spins a selected motor for a specific amount of rotation using the current motor velocity, measured in degrees or turns.
spin [IntakeMotor v] [intake v] for [90] [degrees v] ▶
Parameters |
Description |
|---|---|
motor |
The motor to spin:
|
direction |
The direction to spin:
|
distance |
The rotation amount, as an integer or decimal. |
unit |
The unit of measurement representing the distance:
|
expanding arrow |
By default, this is a waiting block, so the motor will finish moving before running the next block. Expand the block to say and don’t wait to make it non-waiting. |
Example
cuando empezó
[Collect the preloaded Disc.]
spin [IntakeMotor v] [intake v] for [180] [degrees v] ▶
spin motor to position#
The spin motor to position block spins a motor to a specific absolute position using the current motor velocity and motor position.
spin [ArmMotor v] to position [90] [degrees v] ▶
Parameters |
Description |
|---|---|
motor |
The motor to spin:
|
position |
The target position to spin the motor to. |
unit |
The unit of measurement:
|
expanding arrow |
By default, this is a waiting block, so the motor will finish moving before running the next block. Expand the block to say and don’t wait to make it non-waiting. |
Example
cuando empezó
[Raise the Arm to reach over the barrier.]
spin [ArmMotor v] to position [600] [degrees v] ▶
stop motor#
The stop motor block immediately stops the selected motor.
stop [IntakeMotor v]
Parameters |
Description |
|---|---|
motor |
The motor to stop:
|
Example
cuando empezó
[Raise the Arm for 1 second, then stop.]
girar [ArmMotor v] [arriba v]
esperar (1) segundos
parada [ArmMotor v]
Settings#
set motor velocity#
The set motor velocity block sets the default spinning speed of a motor as a percentage for all subsequent Motor blocks in the project.
set [IntakeMotor v] velocity to [50] [% v]
Parameters |
Description |
|---|---|
motor |
The motor to set the velocity of:
|
velocity |
Sets the default movement velocity from 0 to 100 as a percent. |
unit |
The unit that represents the velocity:
|
Example
cuando empezó
[Spin the Intake Motor at 75 percent speed.]
set [IntakeMotor v] velocity to [75] [% v]
spin [IntakeMotor v] [intake v] for [180] [degrees v] ▶
set motor timeout#
The set motor timeout block sets a time limit for how long a Motor 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.
Establezca el tiempo de espera [ArmMotor v] en [1] segundo
Parameters |
Description |
|---|---|
motor |
The motor to set the timeout of:
|
time |
The maximum number of seconds a Motor block will run before stopping and moving to the next block. |
Example
cuando empezó
[Limit how long the Arm Motor will wait to move.]
set [ArmMotor v] timeout to [2] seconds
spin [ArmMotor v] [up v] for [3] [turns v] ▶
Position#
motor position#
The motor position block returns the total distance the selected motor has rotated.
([IntakeMotor v] position in [degrees v])
Parameters |
Description |
|---|---|
motor |
The motor to return the position of:
|
unit |
The unit of measurement:
|
set motor position#
The set motor position block sets a specific position value to a motor, which updates the encoder reading.
set [IntakeMotor v] position to [0] [degrees v]
Parameters |
Description |
|---|---|
motor |
The motor to set the position of:
|
position |
The encoder position value to set. |
unit |
The unit of measurement:
|
Example
cuando empezó
[Set the Intake Motor position, then spin back to 0 degrees.]
set [IntakeMotor v] position to [180] [degrees v]
spin [IntakeMotor v] to position [0] [degrees v] ▶
Values#
motor is done#
The motor is done? block returns a Boolean indicating whether the motor is not spinning.
True - The motor is not spinning.
False - The motor is spinning.
<[IntakeMotor v] is done?>
Parameters |
Description |
|---|---|
motor |
The motor to check if it is done spinning:
|
motor is spinning?#
The motor is spinning? block returns a Boolean indicating whether the motor is spinning.
True - The motor is spinning.
False - The motor is not spinning.
<[IntakeMotor v] is spinning?>
Parameters |
Description |
|---|---|
motor |
The motor to check if it is currently spinning:
|
motor velocity#
The motor velocity block returns the current rotational speed of the motor in a range from -100% to 100%.
([IntakeMotor v] velocity in [% v] :: custom-motion)
Parameters |
Description |
|---|---|
motor |
The motor to return the velocity of:
|
unit |
The unit that represents the velocity:
|
Sensing#
Optical#
Optical found an object?#
The Optical found an object? block returns a Boolean indicating whether the Optical Sensor has detected an object.
True - The Optical Sensor has detected an object.
False - The Optical Sensor has not detected an object.
<[FrontOptical v] found an object?>
Parameters |
Description |
|---|---|
This block has no parameters. |
Optical detects color#
The Optical detects color? block returns a Boolean indicating whether the Optical Sensor has detected a specific color.
True - The Optical Sensor has detected the specified color.
False - The Optical Sensor has not detected the specified color.
<[FrontOptical v] detects [red v]?>
Parameters |
Description |
|---|---|
color |
Which color to check for:
|
Optical brightness#
The Optical brightness block returns the amount of light detected by the Optical Sensor in a range from 0% to 100%.
([FrontOptical v] brightness in %)
Parameters |
Description |
|---|---|
This block has no parameters. |
Optical hue#
The Optical hue block returns the hue value of the color detected by the Optical Sensor.
Hue values range from 0 to 359 degrees, corresponding to positions on the color wheel shown below.

([FrontOptical v] hue in degrees)
Parameters |
Description |
|---|---|
This block has no parameters. |
when Optical#
The when Optical block runs its stack when the Optical Sensor detects or loses an object. You can have multiple when Optical blocks to run multiple stacks of blocks at once.
when [FrontOptical v] [detects v] an object :: hat events
Parameters |
Description |
|---|---|
action |
Which action triggers the hat block:
|