Bumper#
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
<[LeftBumper v] pressed?>
Parameters |
Description |
|---|---|
bumper sensor |
The Bumper Sensor to check. |
Example
when started :: hat events
[Back up and turn whenever the bumper runs into an object.]
forever
drive [forward v]
if <[LeftBumper 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 [LeftBumper v] [pressed v] :: hat events
Parameters |
Description |
|---|---|
bumper sensor |
The Bumper Sensor to check. |
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 started :: hat events
drive [forward v]
when [LeftBumper v] [pressed v] :: hat events
[Reverse when the left bumper is pressed.]
drive [reverse v] for [200] [mm v] ▶