AddressableLed#

Initializing the AddressableLed Class#

An AddressableLed is created by using the following constructor:

AddressableLed(port)

This constructor uses one parameter:

Parameter

Description

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.

Class Methods#

clear()#

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

Returns: None.

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

Parameters

Description

data

A list of Color values. This includes predefined colors, hex values, and webstrings.

offset

Optional. The index of LED to start at, with index 0 being the first index.

Returns: None.

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