/ Pumpkin_Goblin_CPB_Ornament / code.py
code.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 """ 6 This example shows different ways to use AnimationGroup: syncing four animations across two separate 7 pixel objects such as the built-in NeoPixels on a Circuit Playground Bluefruit and a NeoPixel Ring. 8 9 This example is written for Circuit Playground Bluefruit and a 16-pixel NeoPixel ring connected to 10 pad A1. It does not work on Circuit Playground Express. 11 """ 12 import board 13 import neopixel 14 from adafruit_circuitplayground import cp 15 16 from adafruit_led_animation.animation.blink import Blink 17 from adafruit_led_animation.animation.comet import Comet 18 from adafruit_led_animation.animation.pulse import Pulse 19 from adafruit_led_animation.animation.sparkle import Sparkle 20 21 from adafruit_led_animation.group import AnimationGroup 22 from adafruit_led_animation.sequence import AnimationSequence 23 24 import adafruit_led_animation.color as color 25 26 strip_pixels = neopixel.NeoPixel(board.A1, 16, brightness=0.5, auto_write=False) 27 cp.pixels.brightness = 0.5 28 29 animations = AnimationSequence( 30 # Synchronized to 0.5 seconds. Ignores the second animation setting of 3 seconds. 31 AnimationGroup( 32 Sparkle(cp.pixels, 0.1, color.GREEN, num_sparkles=1), 33 Sparkle(strip_pixels, 0.1, color.GREEN, num_sparkles=1), 34 ), 35 AnimationGroup( 36 Blink(cp.pixels, 0.25, color.RED), 37 Blink(strip_pixels, 0.25, color.RED), 38 sync=True, 39 ), 40 # Different speeds 41 AnimationGroup( 42 Comet(cp.pixels, 0.05, color.GREEN, tail_length=5), 43 Comet(strip_pixels, 0.05, color.GREEN, tail_length=5), 44 ), 45 AnimationGroup( 46 Pulse(cp.pixels, 0.05, color.RED, period=3), 47 Pulse(strip_pixels, 0.05, color.RED, period=3), 48 ), 49 advance_interval=4.0, 50 auto_clear=True, 51 auto_reset=True, 52 ) 53 54 while True: 55 animations.animate()