Skip to content

How I create and use a 3x3-LED object? #525

Answered by laurensvalk
Lebostein asked this question in Q&A
Discussion options

You must be logged in to vote

You can use this example, adapted from #440.

from pybricks.pupdevices import ColorLightMatrix
from pybricks.parameters import Port, Color
from pybricks.tools import wait

from urandom import randint

color_matrix = ColorLightMatrix(Port.B)

# Static single color example
color_matrix.on(Color.ORANGE)
wait(1000)

# Static multi color example
color_matrix.on([Color.RED, Color.WHITE, Color.BLUE] * 3)
wait(1000)

# Fade example
for i in range(3):
    for brightness in tuple(range(0, 110, 10)) + tuple(range(100, -10, -10)):
        color_matrix.on(Color.BLUE * (brightness / 100) )
        wait(50)

# Randomness
for i in range(1000):
    color_matrix.on([Color(randint(0, 360), v=40) for i in range(

Replies: 2 comments 1 reply

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@Lebostein
Comment options

Answer selected by Lebostein
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants