Events#

When started#

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

when_started_block

A when started event will run when the project is started from the start button in VEXcode VR 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.

when_started_example

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

Choose which Bumper to use.

when_bumper_select

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

when_bumper_condition

In this example, when the Bumper Switch sensor is pressed, the robot will stop moving.

when_bumper_example

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

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.

when_timer_select

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

when_timer_example

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.

when_receive_block

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

when_receive_select

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.

when_receive_example

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.

broadcast_block

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.

broadcast_select

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.

when_receive_example

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.

broadcast_wait_block

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.

broadcast_wait_select

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.

broadcast_wait_example

When Eye Sensor#

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

when_eye_sensor_block

The When Eye Sensor event can be used to create actions or behaviors based on whether the Eye Sensor detects an object in range of the sensor or loses an object that was in range of the sensor.

Choose an Eye Sensor.

when_eye_sensor_device

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

when_eye_sensor_condition

In this example, once the Down Eye Sensor has detected an object, the VR Robot will print a message to the Print Console.

when_eye_sensor_example