Parachoques LED#
Introducción#
The LED Bumper can detect when it is pressed and display colors. It can be used to react to the environment by triggering behaviors or lighting up different colors.
For the examples below, the configured LED Bumper will be named bumper. This name is used in all subsequent examples throughout this API documentation when referring to LEDBumper class methods.
A continuación se muestra una lista de todos los métodos:
Mutadores: cambian los colores y el brillo.
set_color— Sets the color of the LED Bumper.set_brightness— Sets the brightness of the LED Bumper.
Obtenedores: devuelven datos del paragolpes LED.
is_pressed— Returns whether or not the LED Bumper is being pressed.
Mutadores#
set_color#
set_color sets the color of the LED Bumper, or turns it off.
The LED can be used as a way to track where the robot is at in a project, or to show when certain conditions are met.
The LED Bumper can be used to track where the robot is at in a project or to show when certain conditions are met.
Usage:
bumper.set_color(color)
Parámetros |
Descripción |
|---|---|
|
The color to set the LED Bumper to:
|
# Build Used: Super Code Base 2.0
def main():
# Blink the LED off and on
while True:
bumper.set_color(GREEN)
wait(0.5, SECONDS)
bumper.set_color(OFF)
wait(0.5, SECONDS)
# Start threads — Do not delete
start_thread(main)
set_brightness#
set_brightness sets how bright the LED Bumper is.
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.
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.
Usage:
bumper.set_brightness(color)
Parámetros |
Descripción |
|---|---|
|
The brightness of the LED as a percent from 0% to 100% as a whole number. |
# Build Used: Super Code Base 2.0
def main():
# Light up the LED at different brightness levels
bumper.set_brightness(25)
bumper.set_color(GREEN)
wait(2, SECONDS)
bumper.set_brightness(100)
# Start threads — Do not delete
start_thread(main)
Getters#
is_pressed#
is_pressed returns a Boolean indicating whether or not the LED Bumper is pressed. This can be used to check if the robot bumps into other objects.
True— The LED Bumper is pressed.False— The LED Bumper is not pressed.
Usage:
bumper.is_pressed()
Parámetros |
Descripción |
|---|---|
Este método no tiene parámetros. |
# Build Used: Super Code Base 2.0
def main():
# Turn right when the bumper is pressed
drivetrain.turn(LEFT)
while not bumper.is_pressed():
wait(0.2, SECONDS)
drivetrain.turn(RIGHT)
# Start threads — Do not delete
start_thread(main)