Simple test
Ensure your device works with this simple test.
examples/led_animation_simpletest.py
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"""
10
11import board
12import neopixel
13
14from adafruit_led_animation.animation.blink import Blink
15from adafruit_led_animation.color import RED
16
17# Update to match the pin connected to your NeoPixels
18pixel_pin = board.D6
19# Update to match the number of NeoPixels you have connected
20pixel_num = 32
21
22pixels = neopixel.NeoPixel(pixel_pin, pixel_num, brightness=0.5, auto_write=False)
23
24blink = Blink(pixels, speed=0.5, color=RED)
25
26while True:
27 blink.animate()
Basic Animations
Demonstrates the basic animations.
examples/led_animation_basic_animations.py
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"""
12
13import board
14import neopixel
15
16from adafruit_led_animation.animation.blink import Blink
17from adafruit_led_animation.animation.chase import Chase
18from adafruit_led_animation.animation.colorcycle import ColorCycle
19from adafruit_led_animation.animation.comet import Comet
20from adafruit_led_animation.animation.pulse import Pulse
21from adafruit_led_animation.animation.solid import Solid
22from adafruit_led_animation.color import (
23 AMBER,
24 JADE,
25 MAGENTA,
26 ORANGE,
27 PINK,
28 PURPLE,
29 TEAL,
30 WHITE,
31)
32from adafruit_led_animation.sequence import AnimationSequence
33
34# Update to match the pin connected to your NeoPixels
35pixel_pin = board.D6
36# Update to match the number of NeoPixels you have connected
37pixel_num = 32
38
39pixels = neopixel.NeoPixel(pixel_pin, pixel_num, brightness=0.5, auto_write=False)
40
41solid = Solid(pixels, color=PINK)
42blink = Blink(pixels, speed=0.5, color=JADE)
43colorcycle = ColorCycle(pixels, speed=0.4, colors=[MAGENTA, ORANGE, TEAL])
44chase = Chase(pixels, speed=0.1, color=WHITE, size=3, spacing=6)
45comet = Comet(pixels, speed=0.01, color=PURPLE, tail_length=10, bounce=True)
46pulse = Pulse(pixels, speed=0.1, color=AMBER, period=3)
47
48
49animations = AnimationSequence(
50 solid,
51 blink,
52 colorcycle,
53 chase,
54 comet,
55 pulse,
56 advance_interval=5,
57 auto_clear=True,
58)
59
60while True:
61 animations.animate()
All Animations
Demonstrates the entire suite of animations.
examples/led_animation_all_animations.py
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"""
12
13import board
14import neopixel
15
16from adafruit_led_animation.animation.blink import Blink
17from adafruit_led_animation.animation.chase import Chase
18from adafruit_led_animation.animation.colorcycle import ColorCycle
19from adafruit_led_animation.animation.comet import Comet
20from adafruit_led_animation.animation.customcolorchase import CustomColorChase
21from adafruit_led_animation.animation.pulse import Pulse
22from adafruit_led_animation.animation.rainbow import Rainbow
23from adafruit_led_animation.animation.rainbowchase import RainbowChase
24from adafruit_led_animation.animation.rainbowcomet import RainbowComet
25from adafruit_led_animation.animation.rainbowsparkle import RainbowSparkle
26from adafruit_led_animation.animation.solid import Solid
27from adafruit_led_animation.animation.sparkle import Sparkle
28from adafruit_led_animation.animation.sparklepulse import SparklePulse
29from adafruit_led_animation.color import AMBER, JADE, MAGENTA, ORANGE, PURPLE, WHITE
30from adafruit_led_animation.sequence import AnimationSequence
31
32# Update to match the pin connected to your NeoPixels
33pixel_pin = board.D6
34# Update to match the number of NeoPixels you have connected
35pixel_num = 32
36
37pixels = neopixel.NeoPixel(pixel_pin, pixel_num, brightness=0.5, auto_write=False)
38
39blink = Blink(pixels, speed=0.5, color=JADE)
40colorcycle = ColorCycle(pixels, speed=0.4, colors=[MAGENTA, ORANGE])
41comet = Comet(pixels, speed=0.01, color=PURPLE, tail_length=10, bounce=True)
42chase = Chase(pixels, speed=0.1, size=3, spacing=6, color=WHITE)
43pulse = Pulse(pixels, speed=0.1, period=3, color=AMBER)
44sparkle = Sparkle(pixels, speed=0.1, color=PURPLE, num_sparkles=10)
45solid = Solid(pixels, color=JADE)
46rainbow = Rainbow(pixels, speed=0.1, period=2)
47sparkle_pulse = SparklePulse(pixels, speed=0.1, period=3, color=JADE)
48rainbow_comet = RainbowComet(pixels, speed=0.1, tail_length=7, bounce=True)
49rainbow_chase = RainbowChase(pixels, speed=0.1, size=3, spacing=2, step=8)
50rainbow_sparkle = RainbowSparkle(pixels, speed=0.1, num_sparkles=15)
51custom_color_chase = CustomColorChase(
52 pixels, speed=0.1, size=2, spacing=3, colors=[ORANGE, WHITE, JADE]
53)
54
55
56animations = AnimationSequence(
57 comet,
58 blink,
59 rainbow_sparkle,
60 chase,
61 pulse,
62 sparkle,
63 rainbow,
64 solid,
65 rainbow_comet,
66 sparkle_pulse,
67 rainbow_chase,
68 custom_color_chase,
69 advance_interval=5,
70 auto_clear=True,
71)
72
73while True:
74 animations.animate()
Pixel Map
Demonstrates the pixel mapping feature.
examples/led_animation_pixel_map.py
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"""
14
15import board
16import neopixel
17
18from adafruit_led_animation import helper
19from adafruit_led_animation.animation.chase import Chase
20from adafruit_led_animation.animation.comet import Comet
21from adafruit_led_animation.animation.rainbow import Rainbow
22from adafruit_led_animation.animation.rainbowchase import RainbowChase
23from adafruit_led_animation.animation.rainbowcomet import RainbowComet
24from adafruit_led_animation.color import AMBER, JADE, PURPLE
25from adafruit_led_animation.sequence import AnimationSequence
26
27# Update to match the pin connected to your NeoPixels
28pixel_pin = board.D6
29# Update to match the number of NeoPixels you have connected
30pixel_num = 32
31
32pixels = neopixel.NeoPixel(pixel_pin, pixel_num, brightness=0.5, auto_write=False)
33
34pixel_wing_vertical = helper.PixelMap.vertical_lines(
35 pixels, 8, 4, helper.horizontal_strip_gridmap(8, alternating=False)
36)
37pixel_wing_horizontal = helper.PixelMap.horizontal_lines(
38 pixels, 8, 4, helper.horizontal_strip_gridmap(8, alternating=False)
39)
40
41comet_h = Comet(pixel_wing_horizontal, speed=0.1, color=PURPLE, tail_length=3, bounce=True)
42comet_v = Comet(pixel_wing_vertical, speed=0.1, color=AMBER, tail_length=6, bounce=True)
43chase_h = Chase(pixel_wing_horizontal, speed=0.1, size=3, spacing=6, color=JADE)
44rainbow_chase_v = RainbowChase(pixel_wing_vertical, speed=0.1, size=3, spacing=2, step=8)
45rainbow_comet_v = RainbowComet(pixel_wing_vertical, speed=0.1, tail_length=7, bounce=True)
46rainbow_v = Rainbow(pixel_wing_vertical, speed=0.1, period=2)
47rainbow_chase_h = RainbowChase(pixel_wing_horizontal, speed=0.1, size=3, spacing=3)
48
49animations = AnimationSequence(
50 rainbow_v,
51 comet_h,
52 rainbow_comet_v,
53 chase_h,
54 rainbow_chase_v,
55 comet_v,
56 rainbow_chase_h,
57 advance_interval=5,
58)
59
60while True:
61 animations.animate()
Animation Sequence
Demonstrates the animation sequence feature.
examples/led_animation_sequence.py
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"""
11
12import board
13import neopixel
14
15from adafruit_led_animation.animation.blink import Blink
16from adafruit_led_animation.animation.chase import Chase
17from adafruit_led_animation.animation.comet import Comet
18from adafruit_led_animation.color import AMBER, JADE, PURPLE
19from adafruit_led_animation.sequence import AnimationSequence
20
21# Update to match the pin connected to your NeoPixels
22pixel_pin = board.D6
23# Update to match the number of NeoPixels you have connected
24pixel_num = 32
25
26pixels = neopixel.NeoPixel(pixel_pin, pixel_num, brightness=0.5, auto_write=False)
27
28blink = Blink(pixels, speed=0.5, color=JADE)
29comet = Comet(pixels, speed=0.01, color=PURPLE, tail_length=10, bounce=True)
30chase = Chase(pixels, speed=0.1, size=3, spacing=6, color=AMBER)
31
32
33animations = AnimationSequence(blink, comet, chase, advance_interval=3, auto_clear=True)
34
35while True:
36 animations.animate()
Animation Group
Demonstrates the animation group feature.
examples/led_animation_group.py
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"""
13
14import board
15import neopixel
16from adafruit_circuitplayground import cp
17
18from adafruit_led_animation import color
19from adafruit_led_animation.animation.blink import Blink
20from adafruit_led_animation.animation.chase import Chase
21from adafruit_led_animation.animation.comet import Comet
22from adafruit_led_animation.group import AnimationGroup
23from adafruit_led_animation.sequence import AnimationSequence
24
25strip_pixels = neopixel.NeoPixel(board.A1, 30, brightness=0.5, auto_write=False)
26cp.pixels.brightness = 0.5
27
28animations = AnimationSequence(
29 # Synchronized to 0.5 seconds. Ignores the second animation setting of 3 seconds.
30 AnimationGroup(
31 Blink(cp.pixels, 0.5, color.CYAN),
32 Blink(strip_pixels, 3.0, color.AMBER),
33 sync=True,
34 ),
35 # Different speeds
36 AnimationGroup(
37 Comet(cp.pixels, 0.1, color.MAGENTA, tail_length=5),
38 Comet(strip_pixels, 0.01, color.MAGENTA, tail_length=15),
39 ),
40 # Different animations
41 AnimationGroup(
42 Blink(cp.pixels, 0.5, color.JADE),
43 Comet(strip_pixels, 0.05, color.TEAL, tail_length=15),
44 ),
45 # Sequential animations on the built-in NeoPixels then the NeoPixel strip
46 Chase(cp.pixels, 0.05, size=2, spacing=3, color=color.PURPLE),
47 Chase(strip_pixels, 0.05, size=2, spacing=3, color=color.PURPLE),
48 advance_interval=3.0,
49 auto_clear=True,
50 auto_reset=True,
51)
52
53while True:
54 animations.animate()
Blink
Demonstrates the blink animation.
examples/led_animation_blink.py
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"""
13
14import board
15import neopixel
16
17from adafruit_led_animation.animation.blink import Blink
18from adafruit_led_animation.color import PURPLE
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
27blink = Blink(pixels, speed=0.5, color=PURPLE)
28
29while True:
30 blink.animate()
Blink with a selcted background color
Demonstrates the blink animation with an user defined background color.
examples/led_animation_blink_with_background.py
1# SPDX-FileCopyrightText: 2025 Jose D. Montoya
2# SPDX-License-Identifier: MIT
3
4"""
5This example blinks the LEDs purple with a yellow background 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"""
13
14import board
15import neopixel
16
17from adafruit_led_animation.animation.blink import Blink
18from adafruit_led_animation.color import PURPLE, YELLOW
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
27blink = Blink(pixels, speed=0.5, color=PURPLE, background_color=YELLOW)
28
29while True:
30 blink.animate()
Comet
Demonstrates the comet animation.
examples/led_animation_comet.py
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"""
13
14import board
15import neopixel
16
17from adafruit_led_animation.animation.comet import Comet
18from adafruit_led_animation.color import JADE
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
27comet = Comet(pixels, speed=0.02, color=JADE, tail_length=10, bounce=True)
28
29while True:
30 comet.animate()
Chase
Demonstrates the chase animation.
examples/led_animation_chase.py
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"""
14
15import board
16import neopixel
17
18from adafruit_led_animation.animation.chase import Chase
19from adafruit_led_animation.color import WHITE
20
21# Update to match the pin connected to your NeoPixels
22pixel_pin = board.A3
23# Update to match the number of NeoPixels you have connected
24pixel_num = 30
25
26pixels = neopixel.NeoPixel(pixel_pin, pixel_num, brightness=0.5, auto_write=False)
27
28chase = Chase(pixels, speed=0.1, size=3, spacing=6, color=WHITE)
29
30while True:
31 chase.animate()
Rainbow
Demonstrates the rainbow animations.
examples/led_animation_rainbow_animations.py
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"""
13
14import board
15import neopixel
16
17from adafruit_led_animation.animation.rainbow import Rainbow
18from adafruit_led_animation.animation.rainbowchase import RainbowChase
19from adafruit_led_animation.animation.rainbowcomet import RainbowComet
20from adafruit_led_animation.animation.rainbowsparkle import RainbowSparkle
21from adafruit_led_animation.sequence import AnimationSequence
22
23# Update to match the pin connected to your NeoPixels
24pixel_pin = board.D6
25# Update to match the number of NeoPixels you have connected
26pixel_num = 32
27
28pixels = neopixel.NeoPixel(pixel_pin, pixel_num, brightness=0.5, auto_write=False)
29
30rainbow = Rainbow(pixels, speed=0.1, period=2)
31rainbow_chase = RainbowChase(pixels, speed=0.1, size=5, spacing=3)
32rainbow_comet = RainbowComet(pixels, speed=0.1, tail_length=7, bounce=True)
33rainbow_sparkle = RainbowSparkle(pixels, speed=0.1, num_sparkles=15)
34
35
36animations = AnimationSequence(
37 rainbow,
38 rainbow_chase,
39 rainbow_comet,
40 rainbow_sparkle,
41 advance_interval=5,
42 auto_clear=True,
43)
44
45while True:
46 animations.animate()
Sparkle
Demonstrates the sparkle animations.
examples/led_animation_sparkle_animations.py
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"""
11
12import board
13import neopixel
14
15from adafruit_led_animation.animation.sparkle import Sparkle
16from adafruit_led_animation.animation.sparklepulse import SparklePulse
17from adafruit_led_animation.color import AMBER, JADE
18from adafruit_led_animation.sequence import AnimationSequence
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
27sparkle = Sparkle(pixels, speed=0.05, color=AMBER, num_sparkles=10)
28sparkle_pulse = SparklePulse(pixels, speed=0.05, period=3, color=JADE)
29
30animations = AnimationSequence(
31 sparkle,
32 sparkle_pulse,
33 advance_interval=5,
34 auto_clear=True,
35)
36
37while True:
38 animations.animate()
Pacman
Demonstrates the pacman animation.
examples/led_animation_pacman.py
1# SPDX-FileCopyrightText: 2025 Jose D. Montoya
2# SPDX-License-Identifier: MIT
3
4"""
5This example animates a Pacman on a NeoPixel strip.
6"""
7
8import board
9import neopixel
10
11from adafruit_led_animation.animation.pacman import Pacman
12from adafruit_led_animation.color import WHITE
13
14# Update to match the pin connected to your NeoPixels
15pixel_pin = board.D6
16# Update to match the number of NeoPixels you have connected
17num_pixels = 50
18
19# Create the NeoPixel object
20ORDER = neopixel.GRB
21pixels = neopixel.NeoPixel(
22 pixel_pin,
23 num_pixels,
24 brightness=0.5,
25 auto_write=False,
26 pixel_order=ORDER,
27)
28
29# Create the Pacman animation object
30pacman = Pacman(pixels, speed=0.1, color=WHITE)
31
32# Main loop
33while True:
34 pacman.animate()