LED#
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 available blocks:
set LED color – Set the LED Bumper to a selected color.
set LED brightness – Set the LED Bumper to a specific brightness.
bumper pressed? – Returns a Boolean indicating if the LED Bumper was pressed.
set LED color#
The set LED color block sets the color of the LED Bumper.
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 LED brightness#
The set LED brightness block sets the brightness of the LED Bumper.
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%. |
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? block returns a Boolean indicating whether or not the LED Bumper was pressed.
True – The LED Bumper was pressed.
False – The LED Bumper was not 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]