Parachoques LED#

Introducción#

El parachoques LED puede cambiar el color de su LED y detectar cuándo se presiona.

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:

Mutators — Change colors and brightness.

Getters — Return data from the LED Bumper.

  • is_pressed — Returns whether or not the LED Bumper is being pressed.

Mutadores#

set_color#

set_color establece el color del LED Bumper. Si el LED no está encendido al usar este método, se ajustará el brillo al 100 % para encenderlo.

Usage:
bumper.set_color(color)

Parámetros

Descripción

color

The color to set the LED Bumper to:

  • GREEN
  • OFF
  • RED

# 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 establece el brillo del parachoques LED.

Usage:
bumper.set_brightness(color)

Parámetros

Descripción

color

El brillo del LED como porcentaje de 0% a 100%.

# 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.

  • True — The bumper is pressed.

  • False — The 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)