This sensor is a switch. It tells the robot whether its bumper is pressed (sensor value of 1) or released (sensor value of 0).
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 in the illustration, 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 on or off motors when pressed.
- This sensor can detect walls or objects when the bumper runs into them.
- The sensor can detect other parts of the robot, such as an arm, when it presses in 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
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
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.
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.
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.
while not bumper_1.pressing():
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.