Events#
When started#
The When started block is used to run the attached stack of blocks when the project is started.
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 bumper#
The When bumper block is used to run the attached stack of blocks when the selected Bumper Switch sensor is pressed or released.
Choose which Bumper to use.
Select which action will trigger the event - pressed or released.
In this example, when the Bumper Switch sensor is pressed, the robot will stop moving.
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.
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.
In this example, after 5 seconds have passed, the VR Robot will print the message to the Print Console.
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.
Choose which message to listen for. A new message can also be created.
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.
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.
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.
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
.
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.
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.
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.
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.
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.
Choose whether the When Eye detects/loses event is triggered when the sensor detects an object, or loses an object.
In this example, once the Down Eye Sensor has detected an object, the VR Robot will print a message to the Print Console.