Create the LED
The first thing we'll do is create the LED object. The DotStar object has three required arguments and two optional
arguments. You are required to set the pin you're using for data, set the pin you'll be using for clock, and provide the
number of pixels you intend to use. You can optionally set brightness and auto_write .
DotStars can be driven by any two pins. We've chosen A1 for clock and A2 for data. To set the pins, include the pin
names at the beginning of the object creation, in this case board.A1 and board.A2 .
To provide the number of pixels, assign the variable num_pixels to the number of pixels you'd like to use. In this
example, we're using a strip of 72 .
We've chosen to set brightness=0.1 , or 10%.
By default, auto_write=True , meaning any changes you make to your pixels will be sent automatically. Since True is
the default, if you use that setting, you don't need to include it in your LED object at all. We've chosen to
set auto_write=False . If you set auto_write=False , you must include pixels.show() each time you'd like to send data
GREEN = (0, 255, 0)
TEAL = (0, 255, 120)
CYAN = (0, 255, 255)
BLUE = (0, 0, 255)
PURPLE = (180, 0, 255)
MAGENTA = (255, 0, 20)
WHITE = (255, 255, 255)
while True:
# Change this number to change how long it stays on each solid color.
color_fill(RED, 0.5)
color_fill(YELLOW, 0.5)
color_fill(ORANGE, 0.5)
color_fill(GREEN, 0.5)
color_fill(TEAL, 0.5)
color_fill(CYAN, 0.5)
color_fill(BLUE, 0.5)
color_fill(PURPLE, 0.5)
color_fill(MAGENTA, 0.5)
color_fill(WHITE, 0.5)
# Increase or decrease this to speed up or slow down the animation.
slice_alternating(0.1)
color_fill(WHITE, 0.5)
# Increase or decrease this to speed up or slow down the animation.
slice_rainbow(0.1)
time.sleep(0.5)
# Increase this number to slow down the rainbow animation.
rainbow_cycle(0)