Events#

When Started#

The When Started block is used to run the attached stack of blocks when the project is started.

A yellow rectangular shape with rounded corners containing the white text "when started".

A when started event will run when the project is started from the start button in VEXcode Blocks.

All new projects will automatically include a when started block.

In this example, the When Started block is used to start the project. When the start button is selected, the robot will drive forward, turn right, and drive forward again.

A visual programming interface showing a yellow "when started" block connected to three blue command blocks. The first block reads "drive forward for 200 mm", the second "turn right for 90 degrees", and the third "drive forward for 200 mm". The blocks are interlocked to represent a sequence of instructions.

When Brain Button#

The When Brain Button block is used to run the attached stack of blocks when the selected EXP Brain Button is pressed or released.

Diagram illustrating various event blocks in VEXcode, including When Started, When Bumper, and When Timer.

Choose which EXP Brain Button to use.

Image of the When Brain Button" block used in VEXcode to trigger actions when the Brain Button is pressed or released.

Select which action will trigger the event block: pressed or released.

Flowchart illustrating various event blocks in VEXcode, including When Started and When Controller Button.

In this example, pressing the left Brain Button will print a message to the Brain’s screen.

Diagram illustrating various event blocks in VEXcode, including When Started, When Controller Button, and more.

When Controller Button#

The When Controller Button block is used to run the attached stack of blocks when the selected EXP Controller Button is pressed or released.

When Controller Button block example in VEXcode, showing button press action triggering a message on the Brain's screen.

Choose which EXP Controller Button to use.

Image of the When Controller Button" block used to trigger actions when a controller button is pressed or released.

Select which action will trigger the event block: pressed or released.

Image showing the When Controller Button block in VEXcode, used to trigger actions when a controller button is pressed.

In this example, pressing the A Button on the EXP Controller will print a message to the Brain’s screen.

Illustration of the When Controller Button" block in VEXcode.

When Controller Axis#

The When Controller Axis block is used to run the attached stack of blocks when the selected EXP Controller joystick axis is moved.

When Controller Axis block showing joystick axis movement triggering an event in VEXcode Blocks.

Choose which EXP Controller joystick axis to use.

Image showing the When Controller Axis block in VEXcode, used to trigger actions based on joystick axis movement.

In this example, moving the 4th joystick axis on the EXP Controller will print a message.

Illustration of the When Controller Axis block used to trigger actions based on joystick axis movement in VEXcode.

When Bumper#

The When Bumper block is used to run the attached stack of blocks when the selected Bumper Switch sensor is pressed or released.

When Bumper block example in VEXcode, showing the action triggered by pressing the bumper switch sensor.

Choose which Bumper to use.

Image showing the When Bumper" block used in VEXcode to trigger actions when a bumper switch is pressed or released.

Select which action will trigger the event - pressed or released.

Diagram illustrating the When Bumper" block functionality in VEXcode Blocks programming.

In this example, when the Bumper Switch sensor is pressed, a message will be printed on the Brain.

Image illustrating the When Bumper" block used to trigger actions when a bumper switch sensor is pressed or released.

When Limit#

The When Limit block is used to run the attached stack of blocks when the selected Limit Switch sensor is pressed or released.

Image showing the When Limit block in VEXcode, used to trigger actions when a Limit Switch sensor is pressed or released.

Choose which Limit Switch to use.

Diagram illustrating the functionality of the When Limit block in VEXcode, detailing sensor activation.

Select which action will trigger the event - pressed or released.

Diagram illustrating the When Limit" block functionality in VEXcode.

In this example, when the Limit Switch sensor is pressed, a message will be printed on the Brain.

Diagram illustrating the When Limit" block in VEXcode.

When Timer#

The When Timer block is used to run the attached stack of blocks when the Brain’s timer is equal to the given value.

When Timer block example showing how to trigger actions after a set time in VEXcode Blocks.

The Brain’s timer begins at the beginning of each project or whenever the Brain’s timer is reset.

Choose an amount of time. The when timer event will run once the Brain’s timer is equal to the entered amount.

Flowchart illustrating the different event blocks in VEXcode, including When Started, When Timer, and others.

In this example, after 5 seconds have passed, the Robot will print the message to the Print Console.

Illustration of the When Timer block in VEXcode, showing timer-based event execution for robot actions.

When I Receive#

The When I Receive block is used to run the attached stack of blocks when the selected message is received from a broadcasted message.

Flowchart illustrating the When Started" event block in VEXcode.

Choose which message to listen for. A new message can also be created.

Flowchart illustrating various event blocks in VEXcode, including When Started and When I Receive blocks.

In this example, the code will continuously check if the Left Sensor Bumper was pressed. Once pressed, the When I Recieve block will trigger once the bumper_press message is received.

Diagram illustrating various event blocks in VEXcode, including When Started, When Controller Button, and more.

Broadcast#

The Broadcast block is used to broadcast a message to activate any stacks that begin with a When I Receive block listening for the broadcasted message.

Illustration of the Broadcast block used in VEXcode to send messages for event-driven programming.

The stack that sends the broadcast will continue to run blocks at the same time as other stacks that receive the broadcasted message.

Choose which message to broadcast. A new message can also be created.

Flowchart illustrating different event blocks in VEXcode, including When Started, When Controller Button, and more.

In this example, the code will continuously check if the Left Sensor Bumper was pressed. Once pressed, the Broadcast block will trigger the When I Receive block with the message bumper_press.

Diagram illustrating various event blocks in VEXcode, including When Started, When Controller Button, and more.

Broadcast and Wait#

The Broadcast and Wait block is used to broadcast a message to activate any stacks that begin with a When I Receive block listening for the broadcasted message while also pausing the rest of the stack.

This block broadcasts a message to activate any stacks that begin with a when I receive block listening for the broadcasted message while also pausing the rest of the stack.

Illustration of the Broadcast and Wait" block in VEXcode.

The stack that sends the broadcast and wait will pause until the other stacks that receive the broadcasted message have completed.

Choose which message to broadcast. A new message can also be created.

Flowchart illustrating different event blocks in VEXcode, including When Started, When Controller Button, and more.

In this example, the code will continuously check if the Left Sensor Bumper was pressed. Once pressed, the Broadcast and Wait block will trigger the When I Receive block with the message bumper_press. No code underneath the When Started block will execute until everything underneath the bumper_press When I Receive block is finished.

Flowchart illustrating various event blocks in VEXcode, including When Started, When Controller Button, and more.

When Optical Sensor#

The When Optical Sensor block is used to run the attached stack of blocks when the selected Optical Sensor detects or loses an object.

Diagram illustrating the When Optical Sensor block for detecting gestures in VEXcode Blocks.

Choose an Optical Sensor.

Diagram illustrating the functionality of the When Optical Sensor block in VEXcode Blocks programming.

Choose whether the When Optical detects/loses event is triggered when the sensor detects an object, or loses an object.

Optical sensor detecting a gesture, triggering a message to be printed to the Brain's screen in VEXcode.

In this example, once the Optical Sensor has detected an object, a message will be printed to the Brain.

Diagram illustrating the When Optical Sensor block in VEXcode, showing how it detects gestures.

When Optical Sensor Detects a Gesture#

The When Optical Sensor Detects a Gesture block is used to run the attached stack of blocks when the selected Optical Sensor detects a gesture.

Flowchart illustrating various event blocks in VEXcode, including When Optical Sensor Detects a Gesture.

Important: The When Optical Sensor Detects a Gesture will not work unless the Optical Set Mode block is used to set the Optical Sensor to detect gestures.

Optical Sensor mode selection block for gesture detection in VEXcode Blocks programming environment.

Choose an Optical Sensor.

Diagram illustrating the When Optical Sensor Detects a Gesture block in VEXcode programming.

Choose which gesture will trigger the event block.

Diagram illustrating the When Optical Sensor Detects a Gesture" block in VEXcode programming.

In this example, once the Optical Sensor has detected a left gesture, a message will be printed to the Brain.

Diagram illustrating the use of an Optical Sensor to detect a gesture in VEXcode Blocks programming.

When Control Stopped#

The When Control Stopped block is used to run the attached stack of blocks when the Arm’s control stop has been enabled.

Important: When control stop is enabled in a project, it cannot be disabled without restarting the project.

Image showing the When Control Stopped" block used to trigger actions when control stop is enabled in a robotic arm project.

Select which 6-Axis Robotic Arm to use.

Image showing the When Control Stopped" block in VEXcode.

In this example, once the control stop is enabled, a message saying the control has been enabled will be printed to the Brain’s screen.

Diagram illustrating the When Control Stopped" block in VEXcode.

When Signal Tower Bumper is Pressed#

The When Signal Tower Bumper is Pressed block is used to run the attached stack of blocks when the Signal Tower’s bumper sensor is pressed.

Image of a signal tower with a bumper sensor being pressed in a robotics programming context.

Select which Signal Tower’s bumper sensor to use.

Signal tower with a pressed bumper sensor indicating an event trigger in a robotics programming context.

In this example, the 6-Axis Arm will enable its control stop when the Signal Tower’s bumper sensor is pressed.

Image of a signal tower bumper sensor being pressed in a robotics programming context.