Using the LED Bumper#

Using the LED Bumper

Use the LED Bumper’s pressed? Boolean in VEXcode GO to turn the LED Bumper green while it’s pressed.

  1. Make sure your robot has an LED Bumper connected. See Configuring Devices if you haven’t added one yet.

Screenshot of the Devices tab, showing LEDBumper2 in the list of devices.
  1. Attach a forever block below the when started block.

Check the LED Bumper repeatedly.#
    when started :: hat events
        forever
        end
  1. Inside the forever block, attach an if / else block.

An empty if/else block, inside forever.#
    when started :: hat events
        forever
        if <> then
        else
        end
        end
  1. Drag the LED Bumper’s pressed? Boolean block into the if/else block’s condition slot.

Check whether the LED Bumper is pressed.#
    when started :: hat events
        forever
        if <[LEDBumper2 v] pressed? :: custom-led> then
        else
        end
        end
  1. In the if branch, attach a Set Bumper color block.

The Set Bumper color block, in the if branch.#
    when started :: hat events
        forever
        if <[LEDBumper2 v] pressed? :: custom-led> then
        set [LEDBumper2 v] to [red v] :: custom-led
        else
        end
        end
  1. Change the color parameter to green.

Screenshot of the project, with the if branch's Set Bumper color block's dropdown open, showing red, green, and off options, and green selected.
  1. In the else branch, attach another Set Bumper color block.

The Set Bumper color block, in the else branch.#
    when started :: hat events
        forever
        if <[LEDBumper2 v] pressed? :: custom-led> then
        set [LEDBumper2 v] to [green v] :: custom-led
        else
        set [LEDBumper2 v] to [red v] :: custom-led
        end
        end
  1. Change the color parameter to off.

Screenshot of the finished project, with the else branch's Set Bumper color block's dropdown open, showing red, green, and off options, and off selected.
  1. Make sure your robot is connected to VEXcode. See Connecting to Your Robot if it isn’t connected yet.

Screenshot of the VEXcode GO toolbar, showing the Connect button in a Connected state.
  1. Select Start to run the project, then press the LED Bumper. It will light up green while pressed, and turn off when released.

Screenshot of the VEXcode GO toolbar, with the Start button highlighted.