The VEXcode VR Robot has two Bumper Sensors. The Bumper Sensor can be used with VEXcode VR to report if a Bumper Sensor is pressed on the VEXcode VR Robot.


What is a Bumper Sensor?

VEXcode VR Bumper Callout

A Bumper Sensor is a switch. The Bumper Sensor reports if it is pressed or released.

  • The Bumper Sensor will report a sensor value of 1 when the bumper sensor is being pressed.
  • The Bumper Sensor will report a sensor value of 0 when the bumper sensor is released.

Dashboard bumper

The Bumper Sensor’s value can be viewed in the Dashboard. For more information about the Dashboard, check out the VEXcode VR Dashboard Article.


Common Uses of a Bumper Sensor

Bumper maze wall

The Bumper Sensor can be pressed by walls in the Wall Maze Playground.

Playground walls

The Bumper Sensor can also be pressed by walls surrounding different Playgrounds.


Using the Bumper Sensor in VEXcode VR Blocks

VR Main Screen

To begin programming the Bumper Sensor, you will need to first open VEXcode VR. For more information, check out the Launch - Get Started with VEXcode VR article.

Sensing category

Next, locate the Sensing category in the Tool box and find the <Pressing Bumper> block.

Change the Bumper Sensor

Left_Right_Bumper_Block.png

You can select the Left Bumper or Right Bumper from the drop-down menu.

Boolean blocks

Example Program

The Boolean blocks report a condition as either true or false and fits inside any blocks with hexagonal (six-sided) inputs for other blocks.The Pressing Bumper Boolean block reports “true” if the bumper is pressed and “false” if the bumper is released or not pressed. For more information about Boolean blocks visit the Help or the Block Shapes and Meaning - VEXcode VR article.

The following is an example of a code that will cause the VR Robot to drive forward until it bumps into an object or wall.

C blocks

Example Program

C blocks loop the block(s) within them or check if a condition is true or false. They are shaped to attach stack blocks above, below, or inside them. The Bumper Sensor control blocks are commonly used with conditionals (C blocks), such as the [If then] or [Wait until] blocks. For more information about conditional blocks found in the Control category, visit the Help or the Block Shapes and Meaning - VEXcode VR article.

In the following example, the code will cause the VR Robot to drive in a square forever.


Using the Bumper Sensor in VEXcode VR Python

Screen_Shot_2021-11-11_at_9.49.14_AM.png

To begin programming the Bumper Sensor with Python, you will need to first open a text project VEXcode VR. For more information, see this article.

Screen_Shot_2021-11-11_at_9.50.48_AM.png

Next, locate the Sensing category in the Toolbox and find left_bumper.pressed and right_bumper.pressed commands. These are functions that report a Boolean value about the sensor. Because there are two Bumper Sensors on the VR Robot, there are options for both the right and left bumper.

Screen_Shot_2021-11-11_at_9.55.36_AM.png

To add the command to your project, you can drag the command in from the Toolbox, or type out the command in the workspace using the Autocomplete function. To learn more about Autocomplete in VEXcode VR with Python, see this article.

Screen_Shot_2021-11-11_at_10.25.56_AM.png

A while loop can be used with sensors on your robot when you want your robot to do something like drive until the Bumper Switch is pressed, then stop or turn.

In this project, the robot will drive forward while the Bumper Switch is not pressed, and will turn right 90 degrees when the Bumper Switch is pressed.

For more information, help, and tips, check out the many resources at VEX Professional Development Plus