LED direccionable#

Inicializando la clase AddressableLed#

Un AddressableLed se crea utilizando el siguiente constructor:

AddressableLed(port)

Este constructor utiliza un parámetro:

Parámetro

Descripción

port

The 3-Wire Port that the AddressableLed is connected to, whether it’s a port on the Brain, or a 3-Wire Expander.

A Brain or 3-Wire Expander must be created first before they can be used to create an object with the AddressableLed Class constructor.

# Create the Brain.
brain = Brain()
# Construct an AddressableLed "addled" with the
# AddressableLed class.
addled = AddressableLed(brain.three_wire_port.a)

This addled object will be used in all subsequent examples throughout this API documentation when referring to Accelerometer class methods.

Métodos de clase#

clear()#

The clear() method clears the Addressable LED to off.

Devoluciones: Ninguna.

# Set the Addressable LED to red.
addled.set(Color.RED)

# Wait 2 seconds.
wait(2, SECONDS)

# Clears the Addressable LED strip to off.
addled.clear()

set()#

The set(data, offset) method sets the Addressable LED strip to provided values.

Parámetros

Descripción

data

Una lista de valores Color. Esto incluye colores predefinidos, valores hexadecimales y cadenas web.

offset

Opcional. El índice del LED donde se comenzará, siendo el índice 0 el primer índice.

Devoluciones: Ninguna.

# Create a list of HexCode colors assigned to the
# variable, pix.
pix = [Color(0x800000),Color(0x008000),Color(0x000080)]

# Sets the Addressable LED strip to the colors in
# the list pix.
addled.set(pix)