Blocks#
The VEX IQ (2nd gen) Blocks API Reference explains what each VEXcode block does, how its inputs change the robot’s behavior, and how the block can be used in a project.
Use this reference when you want to understand a block before adding it to a project, check what a block reports, or compare similar blocks in a category.
Blocks are used in VEXcode IQ Blocks projects. Python and C++ projects use the text-based API sections instead.
How to Read a Block Entry#
Most block entries include the following parts:
Block description - Explains what the block does and when it is useful.
Block image - Shows what the block looks like in VEXcode IQ.
Parameters - Lists the inputs on the block and explains how each input affects the robot or project.
Return value - Explains what a Boolean or Reporter block reports.
Example - Shows one way the block can be used in a project.
Common Block Types#
Different block shapes have different jobs in a project.
Block Type |
What it means |
|---|---|
Stack |
A block that performs an action. Stack blocks connect above and below other blocks in a stack. |
Hat |
A block that starts a stack of blocks when something happens, such as when the project starts or an event occurs. |
Boolean |
A block that reports True or False. Boolean blocks are often used inside conditions, such as if then or wait until blocks. |
Reporter |
A block that reports a value, such as a number or text. Reporter blocks are often used inside other blocks. |
C block |
A block that wraps around other blocks and controls when or how they run, such as repeating blocks or if then blocks. |
Example Block Entry#
spin motor for#
The spin motor for stack block spins a motor or motor group for a specific distance. The spin is relative to the current position of the motor or motor group. The project will wait until the motor or motor group is done spinning before the next block in the stack runs.
spin [Motor1 v] [forward v] for (90) [degrees v] ▶
Parameters |
Description |
|---|---|
motor |
The motor or motor group to spin. Choose from the motors configured in the Devices window. |
direction |
The direction the motor or motor group spins. By default, the choices are forward and reverse. Direction choices can change depending on the motor’s configuration. |
distance |
The distance the motor or motor group spins. Degrees use integers. Turns can use integers or decimals. |
unit |
The distance unit: degrees or turns. |
and don’t wait |
Select the arrow ( ▶ ) to expand the block to say and don’t wait, so the next block in the stack will run right away. |
Example
when started
[Spin the motor forward once, then reset.]
spin [Motor1 v] [forward v] for (90) [degrees v] ▶
spin [Motor1 v] [reverse v] for (90) [degrees v] ▶