Blocks API
VEX IQ Blocks API Reference Guide
This page is a local reference guide for the main VEX IQ Blocks API categories. It is designed so you can still learn and work even if the VEX documentation site is blocked or unavailable.
Use this page to understand what each block family does, when to use it, and how it connects to the Python ideas you already know. Official API links are included as backup reading.
How to use this page
When you are coding in VEX Blocks, you are usually trying to do one of these jobs:
- start a program
- move the robot or a mechanism
- read controller or sensor input
- make decisions using conditions
- store and reuse data
- organise code more clearly
- debug what is happening
- bridge visual coding into Python thinking
Big idea
Blocks are not “baby code.”
They are a visual way of building real programs using sequence, variables, conditions, loops, events, functions, sensors, and outputs.
Jump menu
1. How the Blocks API is organised
Back to top ↑The official Blocks API is designed so each block entry shows a block name, a description, its parameters, and a worked example. That means you are expected to read a block in terms of what it does, what values it needs, and what it looks like in a real program.
This reference page follows the same pattern, but in teacher-friendly language for class use.
What the block is called in VEXcode.
What the block does in plain language.
The values, devices, directions, or units you must choose.
A real stack showing how the block is used.
2. Events
Back to top ↑Event blocks are about when something starts or when one part of the program triggers another part. The main event blocks are:
- when started
- when I receive event
- broadcast event
- broadcast event and wait
Use events when: you want a project to begin, or when you want one stack to activate another stack.
Official backup link: Events API
3. Drivetrain
Back to top ↑Drivetrain blocks control the whole robot as one moving system. They include:
- Actions: drive, drive for, turn, turn for, turn to heading, turn to rotation, stop driving
- Settings: set drive velocity, set turn velocity, set drive stopping, set drive timeout, set drive heading, set drive rotation
- Values: drive is done?, drive is moving?, drive heading, drive rotation, drive velocity, drive current
Use drivetrain when: the entire robot body should move or turn.
Official backup link: Drivetrain API
4. Motion
Back to top ↑The Motion category is about motors, motor groups, and device-based movement rather than whole-robot drivetrain movement.
- spin motor
- spin motor for
- spin motor to position
- stop motor
- set motor position
- set motor velocity
- set motor stopping
- set motor max torque
- set motor timeout
- motor is done?
- motor is spinning?
- motor position
- motor velocity
- motor current
one mechanism moves separately from the main drivetrain, such as:
- a claw
- a lift
- an arm
- a grabber
Official backup links: Motion API overview | Motors and Motor Groups API
5. Controller
Back to top ↑Controller blocks let the program respond to button presses and joystick movement. Main blocks include:
- controller button pressed?
- controller axis position
- controller enable/disable
- when controller button
- when controller axis is changed
The axes return values from -100 to 100. This is useful for proportional control and reading joystick direction.
Official backup link: Controller API
6. Sensing overview
Back to top ↑Sensing blocks let the robot detect and respond to its environment. The VEX IQ Blocks sensing pages include:
- Brain Sensing
- Bumper Switch
- Touch LED
- Color Sensor
- Distance Sensor
- Optical Sensor
- Inertial and Gyro Sensor
7. Brain Sensing
Back to top ↑Brain Sensing is for reading inputs and values from the robot brain itself. Main blocks:
- brain button pressed?
- battery capacity
- when Brain button
Use these blocks when you want the program to respond to the physical Brain buttons or show system status such as charge level.
Official backup link: Brain Sensing API
8. Bumper Switch
Back to top ↑A bumper switch is a simple pressed/not pressed sensor. It is useful for collision detection or contact detection.
Main ideas:
- check whether the bumper is pressed
- run code when the bumper is pressed or released
9. Touch LED
Back to top ↑Touch LED blocks can both sense touch and control the LED light. Main blocks include:
- set Touch LED color
- set Touch LED fade
- set Touch LED brightness
- Touch LED pressed?
- when Touch LED
This is useful when you want a device that acts as both an input and an output.
Official backup link: Touch LED API
10. Color Sensor
Back to top ↑The Color Sensor is for detecting coloured surfaces or objects and measuring visual data. Main blocks include:
- set Color light
- Color found an object?
- Color detects color?
- Color color name
- Color brightness
- Color hue
Use this when: you need to detect specific colours, check whether an object is present, or compare brightness/hue values.
Official backup link: Color Sensor API
11. Distance Sensor
Back to top ↑The Distance Sensor measures how far away an object is and gives other object information. Main 2nd gen blocks include:
- object distance
- object velocity
- object size is?
- Distance found an object?
Use this when: you need the robot to stop near something, detect whether something is in front of it, or react differently depending on object distance or size.
Official backup link: Distance Sensor API
12. Optical Sensor
Back to top ↑The sensing overview includes an Optical Sensor category for detecting objects, colours, hue, and brightness. In practice, it is similar in purpose to colour-based sensing, but it is a different device category in the VEX docs.
Use this when: the configured device for the task is an Optical Sensor rather than a Color Sensor, and you need visual data from the environment.
13. Inertial and Gyro Sensor
Back to top ↑The IQ Brain includes a built-in Inertial Sensor, and the VEX docs also support an external Gyro Sensor. The main blocks include:
- calibrate gyro
- calibrate BrainInertial
- set Inertial/Gyro heading
- set Inertial/Gyro rotation
- angle of Inertial/Gyro heading
- angle of Inertial/Gyro rotation
- rate of gyro
- acceleration
- gyro rate
- orientation
Use this when: your program needs heading, rotation, tilt, orientation, or motion data.
Official backup link: Inertial and Gyro API
14. Screen
Back to top ↑Screen blocks control the Brain Screen. They are especially useful for debugging and live feedback. The Screen category includes:
print on screen, set cursor, next row, clear row, cursor column, cursor row
clear screen, set font, print precision, pen width, pen/font colour, fill colour
draw pixel, line, rectangle, circle
Use screen blocks when: you want to show sensor values, status messages, simple interfaces, or visual debugging clues.
Official backup link: Screen API
15. Control
Back to top ↑Control blocks manage program flow. These include:
- wait
- wait until
- repeat
- forever
- repeat until
- while
- if
- if / else
- if / else if / else
- break
- stop project
These are the “thinking shape” of your code. They decide whether something repeats, pauses, branches, or stops.
Official backup link: Control API
16. Operators
Back to top ↑Operator blocks do maths, comparisons, logic, and text handling. The official page includes:
- math operator
- comparison operator
- logical operator
- not operator
- range operator
- pick random
- round number
- math functions
- atan2
- remainder
- join
- letter
- length
- contains
- convert
Official backup link: Operators API
17. Variables
Back to top ↑Variables store data. The VEX Blocks variables page includes:
- Numeric Variables: numeric variable, set numeric variable, change numeric variable
- Boolean Variables: Boolean variable, set Boolean variable
- Lists: list item, replace list item, set list items, length of list
- 2D Lists: 2D list item, replace 2D list item, set 2D list items, length of 2D list
All variables are global by default in VEX Blocks, which means they can be used anywhere in the project once created.
Official backup link: Variables API
18. My Blocks
Back to top ↑My Blocks are the Blocks version of functions. They let you define a reusable named chunk of code, with or without parameters.
- My Blocks
- My Blocks with Parameters
Use this when: you keep repeating the same code pattern and want to organise your project more cleanly.
Official backup link: My Blocks API
20. Switch blocks
Back to top ↑Switch blocks are special bridge blocks that let you write Python directly inside the Blocks environment. They help students move from block-based coding toward text-based coding without fully leaving the visual environment.
The Switch page describes several block shapes:
- Stack
- C Block
- C Expandable
- Boolean
- Reporter
- Hat
Why this matters: Switch blocks are one of the clearest built-in bridges between visual coding and Python syntax.
Official backup link: Switch API
21. Blocks → Python bridge
Back to top ↑This is the most important connection for this term: Blocks and Python are not separate worlds. They are different ways of expressing the same programming ideas.
| Blocks idea | Meaning | Python link |
|---|---|---|
| when started | where execution begins | top of a script / starting flow |
| if / else | decision making | if / elif / else |
| repeat / while / forever | repetition | for / while loops |
| variables | stored data | variables |
| My Blocks | reusable named code | functions |
| Switch blocks | typed Python inside Blocks | direct syntax bridge |
Quick self-check
- Can you explain the difference between drivetrain and motion / motor blocks?
- Can you name at least four sensing categories from the API?
- Can you explain when to use control blocks and when to use event blocks?
- Can you explain how operators work inside conditions?
- Can you explain why Switch blocks matter for moving toward Python?
19. Comments
Back to top ↑Comments are notes written inside the project. They do not change how the program runs. They help explain logic, label sections, and record your thinking.
Main block: comment
Official backup link: Comments API