Using Bumper Switch with VEX EXP

Description

This sensor is a switch. It tells the robot whether its bumper is pressed (sensor value of 1) or released (sensor value of 0).

VEX Bumper Switch piece.


How the Bumper Switch Works: Completing the Circuit

The VEX Bumper Switch is based on probably the most commonly used electrical device: the switch. A switch consists of two terminals (places to attach a wire) and a wire bridge to 'make' the connection when the switch is pressed. As shown in the animation below, when you press on the connecting wire, you 'complete' the circuit, and the Robot Brain registers that in your program.

The Bumper Switch is a part of a circuit which is unconnected, or broken. When you press the Bumper Switch, the connection is made, and electricity is allowed to flow.


Setup of the Bumper Switch

Placement

Angled view of the BaseBot build. The robot has an attached Bumper Switch that is highlighted and pointing in front of the robot.

The placement of the Bumper Switch is very important to obtaining accurate readings.

Be sure no structure on the robot is in front of the button on the face of the sensor.

There needs to be a clear path in front of the sensor between any object being pressed against and the sensor.

Reading Bumper Switch Results

VEXcode EXP blocks project that uses a Bumper Switch and Print blocks to report if the switch is pressed. The project reads When started, set font to Mono Small on Brain. Next is a Forever loop with 4 blocks in it. The 4 blocks read Clear all rows on Brain, set cursor to row 1 column 1 on Brain, print Bumper pressed? on Brain and set cursor to next row, and lastly print BumperA pressed? on Brain. The project is shown running on an EXP Brain to the side, and the screen reads Bumper pressed? True.

It is helpful to use the print blocks to print the results of the Bumper Switch.

Once you create and run a project that prints Bumper Switch results, you will be able to see them on the Brain's screen.


Adding the Bumper Switch as a Device in VEXcode EXP

Whenever a sensor is used with a programming language, it needs to be configured within that language.

VEXcode EXP Devices menu after the Add a device button has been selected. The 3 Wire option is highlighted.

With VEXcode EXP, this is accomplished by using the ‘Add a device’ feature from the Devices window. You will need to go to the 3-Wire sensors.

VEXcode EXP Devices menu after the 3 Wire option has been selected. The Bumper option is highlighted.

In the 3-Wire section of Devices you will find the Bumper Switch

To add the Bumper Switch to the configuration, follow the steps in this article.

Screenshot of VEXcode EXP with the Devices menu open. A connected Bumper Switch is listed and highlighted in the Devices menu. The blocks Toolbox is open and the Bumper Sensing cateogory of blocks is highlighted.

Once the Bumper Switch has been added to your project, a new set of sensor blocks will become available.

For more information on the blocks from the ‘Sensing’ category pertaining to the Bumper Switch, view the Help information (Blocks project).


Common Uses of the Bumper Switch

Sensing a Press

VEXcode EXP blocks project that uses a Bumper Switch to drive forwards until it touches an object or wall. The project reads When started, drive forward, wait until BumperA pressed, and then stop driving.

This feature allows your robot to detect when something presses on the Bumper Switch.

The example project shown on the left is used to code a robot with a Bumper Switch mounted on the front to drive until the sensor is pressed, and then stop driving once the Bumper Switch has been pressed.

Bumper Events

VEXcode EXP blocks project that has two small stacks of blocks. The first stack has a When started block followed by a Repeat block set to repeat 4 times. In the Repeat block, there are 2 blocks that read Drive forward for 500 mm, and then Turn right for 90 degrees. The second stack of blocks reads When BumperA pressed, Print BumperA pressed? on Brain and set cursor to next row.

This feature allows your program to run specific code when detecting something pressing on the Bumper Switch.

The example project shown on the left is used to code a robot with a Bumper Switch mounted on the front to drive in a square, and anytime the Bumper Switch is pressed the Brain will print True.

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

Last Updated: