How I create and use a 3x3-LED object? #525
-
Hi, I saw an example with the new Spike 3x3-light matrix on the pybricks channel on YouTube. How I use this light matrix with pybricks? How I can find a code example? Thanks! |
Beta Was this translation helpful? Give feedback.
Answered by
laurensvalk
Nov 10, 2021
Replies: 2 comments 1 reply
-
It doesn't appear that we have added to the documentation yet, but there is a |
Beta Was this translation helpful? Give feedback.
0 replies
-
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(9)])
wait(200) |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
Lebostein
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You can use this example, adapted from #440.