Bumper Switch#
Introduction#
The Bumper Switch is a mechanical switch that completes a circuit when pressed, allowing the robot to detect presses and releases.
Below is a list of available blocks:
Bumper pressed — Reports a Boolean indicating if the Bumper Switch is being pressed.
when Bumper — Runs the attached stack of blocks when the Bumper Switch is pressed or released.
Bumper pressed#
The Bumper pressed Boolean block reports whether or not a Bumper Switch is being pressed. This can be used to check if the robot bumps into other objects.
True — The Bumper Switch is being pressed.
False — The Bumper Switch is not being pressed
<[Bumper1 v] pressed?>
Parameters |
Description |
|---|---|
bumper switch |
The Bumper Switch to check, configured in the Devices window. |
Example
when started
[Back up and turn whenever the bumper runs into an object.]
forever
drive [forward v]
if <[Bumper1 v] pressed?> then
drive [reverse v] for (100) [mm v] ▶
turn [right v] for (90) degrees ▶
when Bumper#
The when Bumper hat block runs the attached stack of blocks when the selected Bumper Switch is pressed or released.
when [Bumper1 v] [pressed v]
Parameters |
Description |
|---|---|
bumper switch |
The Bumper Switch to check, configured in the Devices window. |
state |
When the attached stack of blocks will run: pressed will run when the Bumper Switch is pressed down, and released runs when the Bumper Switch is released. |
Example
when [Bumper1 v] [pressed v]
[Move forward when Bumper Switch is pressed.]
drive [forward v] for [200] [mm v] ▶