Using the Bumper Sensor in VEXcode VR

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?

Diagram illustrating the key features of the VEXcode VR robot, highlighting its components and functionalities within the online programming environment designed for learning coding concepts and robotics.

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.

Diagram illustrating the key features of the VEXcode VR robot, highlighting its capabilities in programming, simulation, and educational applications for STEM learning.

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

Diagram illustrating the features of the VEXcode VR robot, highlighting components such as sensors, wheels, and programming interface, designed to enhance learning in coding and robotics for students and educators.

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

Diagram showcasing the features of the VEXcode VR robot, highlighting its capabilities in programming, simulation, and educational applications for STEM learning.

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


Using the Bumper Sensor in VEXcode VR Blocks

Diagram illustrating the features of the VEXcode VR robot, showcasing various components and functionalities designed to enhance coding education and robotics learning for students and educators.

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.

Diagram showcasing the key features of the VEXcode VR robot, highlighting its components and functionalities within an online programming environment for learning coding concepts and robotics.

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

Change the Bumper Sensor

Diagram illustrating the features of the VEXcode VR robot, highlighting its components and functionalities within the online programming environment designed for learning coding concepts through virtual robotics.

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

Boolean blocks

Diagram illustrating the features of the VEXcode VR robot, highlighting components and functionalities that support coding education and robotics principles for students and educators in a virtual environment.

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

Diagram illustrating the features of the VEXcode VR robot, highlighting components and functionalities that support coding education and robotics principles for students and educators in a virtual environment.

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

Diagram illustrating the features of the VEXcode VR robot, highlighting its capabilities in an online programming environment for learning coding concepts through a virtual robot simulation.

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.

Diagram illustrating the features of the VEXcode VR robot, highlighting its components and capabilities in a virtual programming environment for educational purposes.

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.

Diagram illustrating the key features of VEXcode VR robots, including sensors, motors, and design elements, highlighting their functionality in a virtual programming environment for educational purposes.

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.

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

Last Updated: