Bumper Switch#

Introduction#

The Bumper Switch is a spring-loaded digital sensor that detects physical contact or impact with an object.

The VEX V5 Bumper Switch that is red.

Below is a list of available blocks:

  • Bumper Switch pressed? – Returns whether the specified Bumper Switch is currently pressed.

  • when Bumper Switch – Runs the attached stack of blocks when the specified Bumper Switch is pressed or released.

Bumper Switch pressed?#

The Bumper Switch pressed? block returns a Boolean indicating whether the Bumper Switch is currently being pressed.

  • True – The Bumper Switch is being pressed.

  • False – The Bumper Switch is not being pressed.

  <[BumperSwitchA v] pressed?>

Parameter

Description

device

Which Bumper Switch to use, configured in the Devices window.

  when started
  [Display a message when the Bumper Switch is pressed.]
  wait until <[BumperSwitchA v] pressed?>
  print [Bumper Switch pressed!] on screen ▶

when Bumper Switch#

The when Bumper Switch block runs the attached stack when the specified Bumper Switch is pressed or released.

  when [BumperSwitchA v] [pressed v]  :: hat events

Parameter

Description

device

Which Bumper Switch to use, configured in the Devices window.

state

When to run the attached stack of blocks:

  • pressed
  • released

Drive forward until an object is detected within 200 mm#
  when [BumperSwitchA v] [pressed v]  :: hat events
  [Display a message when the Bumper Switch is pressed.]
  print [Bumper Switch pressed!] on screen ▶