LED Bumper#
Introduction#
The LED Bumper can detect when it is pressed and can change its color or pattern to provide visual feedback.
Below is a list of all blocks:
Set Bumper color — Tells the LED Bumper what color to be.
Set Bumper brightness — Tells the LED Bumper what brightness to be at.
Bumper pressed — Reports a Boolean indicating if the LED Bumper is being pressed.
Set Bumper color#
The Set Bumper color stack block tells the LED Bumper what color to be, or to turn off.
The LED Bumper can be used to track where the robot is at in a project or to show when certain conditions are met.
set [bumper v] to [red v]
Parameters |
Description |
|---|---|
LED |
The selected LED Bumper to change the color of, configured in the Devices window. |
color |
The color to set the LED Bumper to:
|
Example
when started :: hat events
[Build Used: Super Code Base 2.0]
[Blink the LED off and on.]
forever
set [bumper v] to [green v]
wait [0.5] seconds
set [bumper v] to [off v]
wait [0.5] seconds
Set Bumper brightness#
The Set Bumper brightness stack block tells the LED Bumper what brightness to be.
A higher percentage makes the light brighter. A lower percentage makes the light dimmer.
If the LED Bumper is off, setting the light power above 0% will turn the light on.
If the LED Bumper is on, setting the light power at 0% will turn the light off.
set [bumper v] brightness to [50] %
Parameters |
Description |
|---|---|
LED |
The selected LED Bumper to change the brightness of, configured in the Devices window. |
brightness |
The new brightness to set the LED Bumper to from 0% to 100% as a whole number. |
Example
when started :: hat events
[Build Used: Super Code Base 2.0]
[Light up the LED at different brightness levels.]
set [bumper v] brightness to [25] %
set [bumper v] to [green v]
wait [2] seconds
set [bumper v] brightness to [100] %
Bumper pressed#
The Bumper pressed Boolean block reports whether or not the LED Bumper is being pressed. This can be used to check if the robot bumps into other objects.
True — The LED Bumper is being pressed pressed.
False — The LED Bumper is not being pressed.
<[bumper v] pressed?>
Parameters |
Description |
|---|---|
LED |
The selected LED Bumper to check, configured in the Devices window. |
Example
when started :: hat events
[Build Used: Super Code Base 2.0]
[Turn right when the bumper is pressed.]
turn [left v]
wait until <[bumper v] pressed?>
turn [right v]