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? – Returns a Boolean whether the Bumper Switch is being pressed.
when Bumper – Executes the attached stack of blocks when the Bumper Switch is pressed or released.
Bumper pressed?#
The Bumper pressed? block returns if a Bumper Switch is currently being pressed or not pressed. This block returns a Boolean value:
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 :: hat events
[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 block runs the attached stack of blocks when the selected Bumper Switch is pressed or released.
when [Bumper1 v] [pressed v] :: hat events
Parameters |
Description |
---|---|
bumper switch |
The Bumper Switch to check, configured in the Devices window. |
actions |
Determines when the attached stack of blocks will execute:
|
Example
when [Bumper1 v] [pressed v] :: hat events
[Move forward when Bumper Switch is pressed.]
drive [forward v] for [200] [mm v] ▶