Bumper#
Introduction#
The Bumper 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 Sensor is being pressed.
when Bumper – Executes the attached stack of blocks when the Bumper Sensor is pressed or released.
Bumper pressed?#
The bumper pressed? block returns if a Bumper Sensor is currently being pressed or not pressed. This block returns a Boolean value:
True - The Bumper Sensor is being pressed.
False - The Bumper Sensor is not being pressed
<[LeftBumper v] 按下了?>
Parameters |
Description |
|---|---|
bumper sensor |
The Bumper Sensor to check. |
Example
当开始 :: hat events
[Back up and turn whenever the bumper runs into an object.]
永久循环
驱动 [向前 v]
如果 <[LeftBumper v] 按下了?> 那么
驱动 [反 v] (100) [毫米 v] ▶
[右 v] 转 (90) 度 ▶
when Bumper#
The when Bumper block runs the attached stack of blocks when the selected Bumper Sensor is pressed or released.
当 [LeftBumper v] [pressed v] :: hat events
Parameters |
Description |
|---|---|
bumper sensor |
The Bumper Sensor to check. |
actions |
Determines when the attached stack of blocks will execute:
|
Example
当开始 :: hat events
驱动 [向前 v]
当 [LeftBumper v] [pressed v] :: hat events
[Reverse when the left bumper is pressed.]
驱动 [反 v] [200] [毫米 v] ▶