Using the VEX IQ Bumper Switch

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 IQ Bumper Switch piece.


How the Bumper Switch Works: Completing the Circuit

The VEX IQ 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 this animation, when you press on the connecting wire you 'complete' the circuit, and the Robot Brain registers that in your program!

Basically 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.


Common Uses of the Bumper Switch

  • This sensor can trigger a robot action when pressed or released.
  • This sensor can be used as a toggle to turn motors on and off when pressed, as shown in the animation below.

  • This sensor can detect walls or objects when the bumper runs into them, as shown the animation below.

  • The sensor can detect other parts of the robot, such as an arm, when it presses the bumper.

Uses of the Bumper Switch on a Competition Robot

  • While in autonomous mode, a Bumper Switch can be used so that your robot will wait to carry out a certain action until it is pressed by some sort of object.
  • The Bumper Switch can detect when it comes into contact with a surface such as a perimeter wall, or an object such as a game piece.
  • Two Bumper Switches can be used, for example on the front and side of the robot, so that the robot can position itself in a corner. Then the robot can more accurately navigate from that corner to other positions on the competition field. 
  • You can use a Bumper Switch to have your robot detect when one part of it, such as its arm, comes into contact with another part of it, such as its chassis.

Using the Bumper Switch in VEXcode IQ

Adding the Bumper Switch as a Device in VEXcode IQ

VEXcode IQ Devices menu after the Add a device button has been selected. The Bumper option is highlighted.

To code the Bumper Switch in a VEXcode IQ, you must first configure the Bumper Switch. View this article to learn more about configuring a sensor in VEXcode IQ.

Once the Bumper Switch is configured, commands will appear in the Toolbox that you can use in your project.

Coding the Bumper Switch in Blocks

VEXcode IQ Pressing bumper block that reads Bumper1 pressed?

The <Pressing bumper> block is a Boolean reporter block that reports a condition as either true or false. Boolean blocks, like the <Pressing bumper> block fit inside 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. To learn more about Boolean blocks visit the Help or the Block Shapes and Meaning article.

 

VEXcode IQ 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 Bumper1 pressed, and then stop driving.

In this example, the <Pressing bumper> block is used with a [Wait until] block to make the robot drive forward until the Bumper Switch is pressed, as shown in the videos above. 

Coding the Bumper Switch in Python

Note: To code an VEX IQ (1st generation) Bumper Switch in Python, it must be connected to a VEX IQ (2nd generation) Brain. The VEX IQ (1st generation) Brain does not support Python.

bumper_1.pressing()

The bumper.pressing command reports a Boolean value of either true or false about the Bumper Switch. 

The bumper.pressing command reports 'true' if the bumper is pressed, and 'false' if the bumper is released or not pressed.

Note: The name of the Bumper Switch that appears in the command corresponds to the name it is given in the configuration. 

drivetrain.drive(FORWARD)
while not bumper_1.pressing():
wait(20, MSEC)
drivetrain.stop()

In this example, a While loop with a not condition is used with the bumper.pressing command to make the robot drive forward until the Bumper Switch is pressed, as shown in the videos above. 

To learn more about coding a Bumper Switch in Python, check out Unit 4 of the Computer Science Level 1 - Python course. 

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

Last Updated: