Parachoques LED#
Introducción#
El parachoques LED detecta cuando se presiona y muestra colores. Puede utilizarse para reaccionar al entorno activando comportamientos o iluminándose con diferentes colores.
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.
El LED se puede utilizar para rastrear la ubicación del robot en un proyecto o para indicar cuándo se cumplen ciertas condiciones.
El sensor LED puede utilizarse para rastrear la posición del robot en un proyecto o para indicar cuándo se cumplen ciertas condiciones.
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.
Un porcentaje mayor hace que la luz sea más brillante. Un porcentaje menor hace que la luz sea más tenue.
Si el paragolpes LED está apagado, al ajustar la potencia de la luz por encima del 0% se encenderá la luz.
Si el paragolpes LED está encendido, al ajustar la potencia de la luz al 0%, la luz se apagará.
Un porcentaje mayor hace que la luz sea más brillante. Un porcentaje menor hace que la luz sea más tenue.
Si el paragolpes LED está apagado, al ajustar la potencia de la luz por encima del 0% se encenderá la luz.
Si el paragolpes LED está encendido, al ajustar la potencia de la luz al 0%, la luz se apagará.
Usage:
bumper.set_brightness(color)
Parámetros |
Descripción |
|---|---|
|
El brillo del LED como porcentaje, desde el 0% hasta el 100%, expresado como un número entero. |
# 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)