/ examples / led_animation_rainbow_animations.py
led_animation_rainbow_animations.py
 1  # SPDX-FileCopyrightText: 2021 Kattni Rembor for Adafruit Industries
 2  # SPDX-License-Identifier: MIT
 3  
 4  """
 5  This example uses AnimationsSequence to display multiple animations in sequence, at a five second
 6  interval.
 7  
 8  For NeoPixel FeatherWing. Update pixel_pin and pixel_num to match your wiring if using
 9  a different form of NeoPixels.
10  
11  This example does not work on SAMD21 (M0) boards.
12  """
13  import board
14  import neopixel
15  
16  from adafruit_led_animation.animation.rainbow import Rainbow
17  from adafruit_led_animation.animation.rainbowchase import RainbowChase
18  from adafruit_led_animation.animation.rainbowcomet import RainbowComet
19  from adafruit_led_animation.animation.rainbowsparkle import RainbowSparkle
20  from adafruit_led_animation.sequence import AnimationSequence
21  
22  # Update to match the pin connected to your NeoPixels
23  pixel_pin = board.D6
24  # Update to match the number of NeoPixels you have connected
25  pixel_num = 32
26  
27  pixels = neopixel.NeoPixel(pixel_pin, pixel_num, brightness=0.5, auto_write=False)
28  
29  rainbow = Rainbow(pixels, speed=0.1, period=2)
30  rainbow_chase = RainbowChase(pixels, speed=0.1, size=5, spacing=3)
31  rainbow_comet = RainbowComet(pixels, speed=0.1, tail_length=7, bounce=True)
32  rainbow_sparkle = RainbowSparkle(pixels, speed=0.1, num_sparkles=15)
33  
34  
35  animations = AnimationSequence(
36      rainbow,
37      rainbow_chase,
38      rainbow_comet,
39      rainbow_sparkle,
40      advance_interval=5,
41      auto_clear=True,
42  )
43  
44  while True:
45      animations.animate()