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] 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 block runs the attached stack of blocks when the selected Bumper Sensor is pressed or released.

    when [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:

  • pressed
  • 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] ▶