Simple test
Ensure your device works with this simple test.
1# SPDX-FileCopyrightText: 2021 Kattni Rembor for Adafruit Industries
2# SPDX-License-Identifier: MIT
3
4"""
5This simpletest example displays the Blink animation.
6
7For NeoPixel FeatherWing. Update pixel_pin and pixel_num to match your wiring if using
8a different form of NeoPixels.
9"""
10import board
11import neopixel
12from adafruit_led_animation.animation.blink import Blink
13from adafruit_led_animation.color import RED
14
15# Update to match the pin connected to your NeoPixels
16pixel_pin = board.D6
17# Update to match the number of NeoPixels you have connected
18pixel_num = 32
19
20pixels = neopixel.NeoPixel(pixel_pin, pixel_num, brightness=0.5, auto_write=False)
21
22blink = Blink(pixels, speed=0.5, color=RED)
23
24while True:
25 blink.animate()
Basic Animations
Demonstrates the basic animations.
1# SPDX-FileCopyrightText: 2021 Kattni Rembor for Adafruit Industries
2# SPDX-License-Identifier: MIT
3
4"""
5This example displays the basic animations in sequence, at a five second interval.
6
7For NeoPixel FeatherWing. Update pixel_pin and pixel_num to match your wiring if using
8a different form of NeoPixels.
9
10This example may not work on SAMD21 (M0) boards.
11"""
12import board
13import neopixel
14
15from adafruit_led_animation.animation.solid import Solid
16from adafruit_led_animation.animation.colorcycle import ColorCycle
17from adafruit_led_animation.animation.blink import Blink
18from adafruit_led_animation.animation.comet import Comet
19from adafruit_led_animation.animation.chase import Chase
20from adafruit_led_animation.animation.pulse import Pulse
21from adafruit_led_animation.sequence import AnimationSequence
22from adafruit_led_animation.color import (
23 PURPLE,
24 WHITE,
25 AMBER,
26 JADE,
27 TEAL,
28 PINK,
29 MAGENTA,
30 ORANGE,
31)
32
33# Update to match the pin connected to your NeoPixels
34pixel_pin = board.D6
35# Update to match the number of NeoPixels you have connected
36pixel_num = 32
37
38pixels = neopixel.NeoPixel(pixel_pin, pixel_num, brightness=0.5, auto_write=False)
39
40solid = Solid(pixels, color=PINK)
41blink = Blink(pixels, speed=0.5, color=JADE)
42colorcycle = ColorCycle(pixels, speed=0.4, colors=[MAGENTA, ORANGE, TEAL])
43chase = Chase(pixels, speed=0.1, color=WHITE, size=3, spacing=6)
44comet = Comet(pixels, speed=0.01, color=PURPLE, tail_length=10, bounce=True)
45pulse = Pulse(pixels, speed=0.1, color=AMBER, period=3)
46
47
48animations = AnimationSequence(
49 solid,
50 blink,
51 colorcycle,
52 chase,
53 comet,
54 pulse,
55 advance_interval=5,
56 auto_clear=True,
57)
58
59while True:
60 animations.animate()
All Animations
Demonstrates the entire suite of animations.
1# SPDX-FileCopyrightText: 2021 Kattni Rembor for Adafruit Industries
2# SPDX-License-Identifier: MIT
3
4"""
5This example repeatedly displays all available animations, at a five second interval.
6
7For NeoPixel FeatherWing. Update pixel_pin and pixel_num to match your wiring if using
8a different form of NeoPixels.
9
10This example does not work on SAMD21 (M0) boards.
11"""
12import board
13import neopixel
14
15from adafruit_led_animation.animation.blink import Blink
16from adafruit_led_animation.animation.sparklepulse import SparklePulse
17from adafruit_led_animation.animation.comet import Comet
18from adafruit_led_animation.animation.chase import Chase
19from adafruit_led_animation.animation.pulse import Pulse
20from adafruit_led_animation.animation.sparkle import Sparkle
21from adafruit_led_animation.animation.rainbowchase import RainbowChase
22from adafruit_led_animation.animation.rainbowsparkle import RainbowSparkle
23from adafruit_led_animation.animation.rainbowcomet import RainbowComet
24from adafruit_led_animation.animation.solid import Solid
25from adafruit_led_animation.animation.colorcycle import ColorCycle
26from adafruit_led_animation.animation.rainbow import Rainbow
27from adafruit_led_animation.animation.customcolorchase import CustomColorChase
28from adafruit_led_animation.sequence import AnimationSequence
29from adafruit_led_animation.color import PURPLE, WHITE, AMBER, JADE, MAGENTA, ORANGE
30
31# Update to match the pin connected to your NeoPixels
32pixel_pin = board.D6
33# Update to match the number of NeoPixels you have connected
34pixel_num = 32
35
36pixels = neopixel.NeoPixel(pixel_pin, pixel_num, brightness=0.5, auto_write=False)
37
38blink = Blink(pixels, speed=0.5, color=JADE)
39colorcycle = ColorCycle(pixels, speed=0.4, colors=[MAGENTA, ORANGE])
40comet = Comet(pixels, speed=0.01, color=PURPLE, tail_length=10, bounce=True)
41chase = Chase(pixels, speed=0.1, size=3, spacing=6, color=WHITE)
42pulse = Pulse(pixels, speed=0.1, period=3, color=AMBER)
43sparkle = Sparkle(pixels, speed=0.1, color=PURPLE, num_sparkles=10)
44solid = Solid(pixels, color=JADE)
45rainbow = Rainbow(pixels, speed=0.1, period=2)
46sparkle_pulse = SparklePulse(pixels, speed=0.1, period=3, color=JADE)
47rainbow_comet = RainbowComet(pixels, speed=0.1, tail_length=7, bounce=True)
48rainbow_chase = RainbowChase(pixels, speed=0.1, size=3, spacing=2, step=8)
49rainbow_sparkle = RainbowSparkle(pixels, speed=0.1, num_sparkles=15)
50custom_color_chase = CustomColorChase(
51 pixels, speed=0.1, size=2, spacing=3, colors=[ORANGE, WHITE, JADE]
52)
53
54
55animations = AnimationSequence(
56 comet,
57 blink,
58 rainbow_sparkle,
59 chase,
60 pulse,
61 sparkle,
62 rainbow,
63 solid,
64 rainbow_comet,
65 sparkle_pulse,
66 rainbow_chase,
67 custom_color_chase,
68 advance_interval=5,
69 auto_clear=True,
70)
71
72while True:
73 animations.animate()
Pixel Map
Demonstrates the pixel mapping feature.
1# SPDX-FileCopyrightText: 2021 Kattni Rembor for Adafruit Industries
2# SPDX-License-Identifier: MIT
3
4"""
5This example shows usage of the PixelMap helper to easily treat a single strip as a horizontal or
6vertical grid for animation purposes.
7
8For NeoPixel FeatherWing. Update pixel_pin and pixel_num to match your wiring if using
9a different form of NeoPixels. Note that if you are using a number of pixels other than 32, you
10will need to alter the PixelMap values as well for this example to work.
11
12This example does not work on SAMD21 (M0) boards.
13"""
14import board
15import neopixel
16
17from adafruit_led_animation.animation.comet import Comet
18from adafruit_led_animation.animation.rainbowcomet import RainbowComet
19from adafruit_led_animation.animation.rainbowchase import RainbowChase
20from adafruit_led_animation.animation.chase import Chase
21from adafruit_led_animation.animation.rainbow import Rainbow
22from adafruit_led_animation.sequence import AnimationSequence
23from adafruit_led_animation import helper
24from adafruit_led_animation.color import PURPLE, JADE, AMBER
25
26# Update to match the pin connected to your NeoPixels
27pixel_pin = board.D6
28# Update to match the number of NeoPixels you have connected
29pixel_num = 32
30
31pixels = neopixel.NeoPixel(pixel_pin, pixel_num, brightness=0.5, auto_write=False)
32
33pixel_wing_vertical = helper.PixelMap.vertical_lines(
34 pixels, 8, 4, helper.horizontal_strip_gridmap(8, alternating=False)
35)
36pixel_wing_horizontal = helper.PixelMap.horizontal_lines(
37 pixels, 8, 4, helper.horizontal_strip_gridmap(8, alternating=False)
38)
39
40comet_h = Comet(
41 pixel_wing_horizontal, speed=0.1, color=PURPLE, tail_length=3, bounce=True
42)
43comet_v = Comet(pixel_wing_vertical, speed=0.1, color=AMBER, tail_length=6, bounce=True)
44chase_h = Chase(pixel_wing_horizontal, speed=0.1, size=3, spacing=6, color=JADE)
45rainbow_chase_v = RainbowChase(
46 pixel_wing_vertical, speed=0.1, size=3, spacing=2, step=8
47)
48rainbow_comet_v = RainbowComet(
49 pixel_wing_vertical, speed=0.1, tail_length=7, bounce=True
50)
51rainbow_v = Rainbow(pixel_wing_vertical, speed=0.1, period=2)
52rainbow_chase_h = RainbowChase(pixel_wing_horizontal, speed=0.1, size=3, spacing=3)
53
54animations = AnimationSequence(
55 rainbow_v,
56 comet_h,
57 rainbow_comet_v,
58 chase_h,
59 rainbow_chase_v,
60 comet_v,
61 rainbow_chase_h,
62 advance_interval=5,
63)
64
65while True:
66 animations.animate()
Animation Sequence
Demonstrates the animation sequence feature.
1# SPDX-FileCopyrightText: 2021 Kattni Rembor for Adafruit Industries
2# SPDX-License-Identifier: MIT
3
4"""
5This example uses AnimationsSequence to display multiple animations in sequence, at a five second
6interval.
7
8For NeoPixel FeatherWing. Update pixel_pin and pixel_num to match your wiring if using
9a different form of NeoPixels.
10"""
11import board
12import neopixel
13
14from adafruit_led_animation.animation.blink import Blink
15from adafruit_led_animation.animation.comet import Comet
16from adafruit_led_animation.animation.chase import Chase
17from adafruit_led_animation.sequence import AnimationSequence
18from adafruit_led_animation.color import PURPLE, AMBER, JADE
19
20# Update to match the pin connected to your NeoPixels
21pixel_pin = board.D6
22# Update to match the number of NeoPixels you have connected
23pixel_num = 32
24
25pixels = neopixel.NeoPixel(pixel_pin, pixel_num, brightness=0.5, auto_write=False)
26
27blink = Blink(pixels, speed=0.5, color=JADE)
28comet = Comet(pixels, speed=0.01, color=PURPLE, tail_length=10, bounce=True)
29chase = Chase(pixels, speed=0.1, size=3, spacing=6, color=AMBER)
30
31
32animations = AnimationSequence(blink, comet, chase, advance_interval=3, auto_clear=True)
33
34while True:
35 animations.animate()
Animation Group
Demonstrates the animation group feature.
1# SPDX-FileCopyrightText: 2021 ladyada for Adafruit Industries
2# SPDX-FileCopyrightText: 2021 Kattni Rembor for Adafruit Industries
3# SPDX-License-Identifier: MIT
4
5"""
6This example shows three different ways to use AnimationGroup: syncing two animations, displaying
7two animations at different speeds, and displaying two animations sequentially, across two separate
8pixel objects such as the built-in NeoPixels on a Circuit Playground Bluefruit and a NeoPixel strip.
9
10This example is written for Circuit Playground Bluefruit and a 30-pixel NeoPixel strip connected to
11pad A1. It does not work on Circuit Playground Express.
12"""
13import board
14import neopixel
15from adafruit_circuitplayground import cp
16
17from adafruit_led_animation.animation.blink import Blink
18from adafruit_led_animation.animation.comet import Comet
19from adafruit_led_animation.animation.chase import Chase
20
21from adafruit_led_animation.group import AnimationGroup
22from adafruit_led_animation.sequence import AnimationSequence
23
24from adafruit_led_animation import color
25
26strip_pixels = neopixel.NeoPixel(board.A1, 30, brightness=0.5, auto_write=False)
27cp.pixels.brightness = 0.5
28
29animations = AnimationSequence(
30 # Synchronized to 0.5 seconds. Ignores the second animation setting of 3 seconds.
31 AnimationGroup(
32 Blink(cp.pixels, 0.5, color.CYAN),
33 Blink(strip_pixels, 3.0, color.AMBER),
34 sync=True,
35 ),
36 # Different speeds
37 AnimationGroup(
38 Comet(cp.pixels, 0.1, color.MAGENTA, tail_length=5),
39 Comet(strip_pixels, 0.01, color.MAGENTA, tail_length=15),
40 ),
41 # Different animations
42 AnimationGroup(
43 Blink(cp.pixels, 0.5, color.JADE),
44 Comet(strip_pixels, 0.05, color.TEAL, tail_length=15),
45 ),
46 # Sequential animations on the built-in NeoPixels then the NeoPixel strip
47 Chase(cp.pixels, 0.05, size=2, spacing=3, color=color.PURPLE),
48 Chase(strip_pixels, 0.05, size=2, spacing=3, color=color.PURPLE),
49 advance_interval=3.0,
50 auto_clear=True,
51 auto_reset=True,
52)
53
54while True:
55 animations.animate()
Blink
Demonstrates the blink animation.
1# SPDX-FileCopyrightText: 2021 Kattni Rembor for Adafruit Industries
2# SPDX-License-Identifier: MIT
3
4"""
5This example blinks the LEDs purple at a 0.5 second interval.
6
7For QT Py Haxpress and a NeoPixel strip. Update pixel_pin and pixel_num to match your wiring if
8using a different board or form of NeoPixels.
9
10This example will run on SAMD21 (M0) Express boards (such as Circuit Playground Express or QT Py
11Haxpress), but not on SAMD21 non-Express boards (such as QT Py or Trinket).
12"""
13import board
14import neopixel
15
16from adafruit_led_animation.animation.blink import Blink
17from adafruit_led_animation.color import PURPLE
18
19# Update to match the pin connected to your NeoPixels
20pixel_pin = board.A3
21# Update to match the number of NeoPixels you have connected
22pixel_num = 30
23
24pixels = neopixel.NeoPixel(pixel_pin, pixel_num, brightness=0.5, auto_write=False)
25
26blink = Blink(pixels, speed=0.5, color=PURPLE)
27
28while True:
29 blink.animate()
Comet
Demonstrates the comet animation.
1# SPDX-FileCopyrightText: 2021 Kattni Rembor for Adafruit Industries
2# SPDX-License-Identifier: MIT
3
4"""
5This example animates a jade comet that bounces from end to end of the strip.
6
7For QT Py Haxpress and a NeoPixel strip. Update pixel_pin and pixel_num to match your wiring if
8using a different board or form of NeoPixels.
9
10This example will run on SAMD21 (M0) Express boards (such as Circuit Playground Express or QT Py
11Haxpress), but not on SAMD21 non-Express boards (such as QT Py or Trinket).
12"""
13import board
14import neopixel
15
16from adafruit_led_animation.animation.comet import Comet
17from adafruit_led_animation.color import JADE
18
19# Update to match the pin connected to your NeoPixels
20pixel_pin = board.A3
21# Update to match the number of NeoPixels you have connected
22pixel_num = 30
23
24pixels = neopixel.NeoPixel(pixel_pin, pixel_num, brightness=0.5, auto_write=False)
25
26comet = Comet(pixels, speed=0.02, color=JADE, tail_length=10, bounce=True)
27
28while True:
29 comet.animate()
Chase
Demonstrates the chase animation.
1# SPDX-FileCopyrightText: 2021 Kattni Rembor for Adafruit Industries
2# SPDX-License-Identifier: MIT
3
4"""
5This example animates a theatre chase style animation in white with a repeated 3 LEDs lit up at a
6spacing of six LEDs off.
7
8For QT Py Haxpress and a NeoPixel strip. Update pixel_pin and pixel_num to match your wiring if
9using a different board or form of NeoPixels.
10
11This example will run on SAMD21 (M0) Express boards (such as Circuit Playground Express or QT Py
12Haxpress), but not on SAMD21 non-Express boards (such as QT Py or Trinket).
13"""
14import board
15import neopixel
16
17from adafruit_led_animation.animation.chase import Chase
18from adafruit_led_animation.color import WHITE
19
20# Update to match the pin connected to your NeoPixels
21pixel_pin = board.A3
22# Update to match the number of NeoPixels you have connected
23pixel_num = 30
24
25pixels = neopixel.NeoPixel(pixel_pin, pixel_num, brightness=0.5, auto_write=False)
26
27chase = Chase(pixels, speed=0.1, size=3, spacing=6, color=WHITE)
28
29while True:
30 chase.animate()
Rainbow
Demonstrates the rainbow animations.
1# SPDX-FileCopyrightText: 2021 Kattni Rembor for Adafruit Industries
2# SPDX-License-Identifier: MIT
3
4"""
5This example uses AnimationsSequence to display multiple animations in sequence, at a five second
6interval.
7
8For NeoPixel FeatherWing. Update pixel_pin and pixel_num to match your wiring if using
9a different form of NeoPixels.
10
11This example does not work on SAMD21 (M0) boards.
12"""
13import board
14import neopixel
15
16from adafruit_led_animation.animation.rainbow import Rainbow
17from adafruit_led_animation.animation.rainbowchase import RainbowChase
18from adafruit_led_animation.animation.rainbowcomet import RainbowComet
19from adafruit_led_animation.animation.rainbowsparkle import RainbowSparkle
20from adafruit_led_animation.sequence import AnimationSequence
21
22# Update to match the pin connected to your NeoPixels
23pixel_pin = board.D6
24# Update to match the number of NeoPixels you have connected
25pixel_num = 32
26
27pixels = neopixel.NeoPixel(pixel_pin, pixel_num, brightness=0.5, auto_write=False)
28
29rainbow = Rainbow(pixels, speed=0.1, period=2)
30rainbow_chase = RainbowChase(pixels, speed=0.1, size=5, spacing=3)
31rainbow_comet = RainbowComet(pixels, speed=0.1, tail_length=7, bounce=True)
32rainbow_sparkle = RainbowSparkle(pixels, speed=0.1, num_sparkles=15)
33
34
35animations = AnimationSequence(
36 rainbow,
37 rainbow_chase,
38 rainbow_comet,
39 rainbow_sparkle,
40 advance_interval=5,
41 auto_clear=True,
42)
43
44while True:
45 animations.animate()
Sparkle
Demonstrates the sparkle animations.
1# SPDX-FileCopyrightText: 2021 Kattni Rembor for Adafruit Industries
2# SPDX-License-Identifier: MIT
3
4"""
5This example uses AnimationsSequence to display multiple animations in sequence, at a five second
6interval.
7
8For NeoPixel FeatherWing. Update pixel_pin and pixel_num to match your wiring if using
9a different form of NeoPixels.
10"""
11import board
12import neopixel
13
14from adafruit_led_animation.animation.sparkle import Sparkle
15from adafruit_led_animation.animation.sparklepulse import SparklePulse
16from adafruit_led_animation.sequence import AnimationSequence
17from adafruit_led_animation.color import AMBER, JADE
18
19# Update to match the pin connected to your NeoPixels
20pixel_pin = board.D6
21# Update to match the number of NeoPixels you have connected
22pixel_num = 32
23
24pixels = neopixel.NeoPixel(pixel_pin, pixel_num, brightness=0.5, auto_write=False)
25
26sparkle = Sparkle(pixels, speed=0.05, color=AMBER, num_sparkles=10)
27sparkle_pulse = SparklePulse(pixels, speed=0.05, period=3, color=JADE)
28
29animations = AnimationSequence(
30 sparkle,
31 sparkle_pulse,
32 advance_interval=5,
33 auto_clear=True,
34)
35
36while True:
37 animations.animate()