interval. For NeoPixel FeatherWing. Update pixel_pin and pixel_num to match your wiring if using a different form of NeoPixels. """ import board import neopixel from adafruit_led_animation.animation.blink import Blink from adafruit_led_animation.animation.comet import Comet from adafruit_led_animation.animation.chase import Chase from adafruit_led_animation.sequence import AnimationSequence from adafruit_led_animation.color import PURPLE, AMBER, JADE # Update to match the pin connected to your NeoPixels pixel_pin = board.D6 # Update to match the number of NeoPixels you have connected pixel_num = 32 pixels = neopixel.NeoPixel(pixel_pin, pixel_num, brightness=0.5, auto_write=False) blink = Blink(pixels, speed=0.5, color=JADE) comet = Comet(pixels, speed=0.01, color=PURPLE, tail_length=10, bounce=True) chase = Chase(pixels, speed=0.1, size=3, spacing=6, color=AMBER) animations = AnimationSequence(blink, comet, chase, advance_interval=3, auto_clear=True) while True: animations.animate()
anim_mode="circular") group = displayio.Group(max_size=4) group.append(rect1) group.append(rect2) group.append(rect3) group.append(rect4) display.show(group) pixels = rect1 blink = Blink(pixels, speed=0.5, color=0x00FF00) colorcycle = ColorCycle(pixels, speed=0.4, colors=[MAGENTA, YELLOW]) comet = Comet(pixels, speed=0.01, color=PURPLE, tail_length=10, bounce=True) chase = Chase(pixels, speed=0.1, size=3, spacing=6, color=WHITE) #pulse = Pulse(pixels, speed=0.1, period=3, color=0x00FF00) sparkle = Sparkle(pixels, speed=0.1, color=PURPLE, num_sparkles=10) solid = Solid(pixels, color=0x00FF00) #rainbow = Rainbow(pixels, speed=0.1, period=2) sparkle_pulse = SparklePulse(pixels, speed=0.1, period=3, color=0x00FF00) rainbow_comet = RainbowComet(pixels, speed=0.1, tail_length=7, bounce=True) rainbow_chase = RainbowChase(pixels, speed=0.1, size=3, spacing=2, step=8) #rainbow_sparkle = RainbowSparkle(pixels, speed=0.1, num_sparkles=15) custom_color_chase = CustomColorChase(pixels, speed=0.1, size=2, spacing=3, colors=[ORANGE, WHITE, JADE]) blink2 = Blink(rect2, speed=0.5, color=0x0000FF)
auto_write=False) cp.pixels.brightness = 0.5 animations = AnimationSequence( # Synchronized to 0.5 seconds. Ignores the second animation setting of 3 seconds. AnimationGroup( Blink(cp.pixels, 0.5, color.CYAN), Blink(strip_pixels, 3.0, color.AMBER), sync=True, ), # Different speeds AnimationGroup( Comet(cp.pixels, 0.1, color.MAGENTA, tail_length=5), Comet(strip_pixels, 0.01, color.MAGENTA, tail_length=15), ), # Different animations AnimationGroup( Blink(cp.pixels, 0.5, color.JADE), Comet(strip_pixels, 0.05, color.TEAL, tail_length=15), ), # Sequential animations on the built-in NeoPixels then the NeoPixel strip Chase(cp.pixels, 0.05, size=2, spacing=3, color=color.PURPLE), Chase(strip_pixels, 0.05, size=2, spacing=3, color=color.PURPLE), advance_interval=3.0, auto_clear=True, auto_reset=True, ) while True: animations.animate()
pixel_pin = board.D5 # Number of pixels in the collar (arranged in two rows) pixel_num = 24 pixels = neopixel.NeoPixel(pixel_pin, pixel_num, brightness=0.5, auto_write=False) # Create a switch from the ItsyBity's on-board pushbutton to toggle charge mode mode_pin = digitalio.DigitalInOut(board.SWITCH) mode_pin.direction = digitalio.Direction.INPUT mode_pin.pull = digitalio.Pull.UP switch = Debouncer(mode_pin) # Create the animations comet = Comet(pixels, speed=0.06, color=(180,0,255), tail_length=10, bounce=True) chase = Chase(pixels, speed=0.05, size=3, spacing=3, color=(0,255,255), reverse=True) rainbow_comet = RainbowComet(pixels, speed=.06) pulse = Pulse(pixels, speed=.04, color=(255,0,0), period = 0.2) # Our animations sequence seconds_per_animation = 10 animations = AnimationSequence(comet, rainbow_comet, chase, advance_interval=seconds_per_animation, auto_clear=True) # Current display determines whether we are showing the animation sequence or the pulse animation current_display = animations # Mode changes the color of random animations randomly random_color_mode = True def random_animation_color(anims): if random_color_mode:
) # Update to match the pin connected to your NeoPixels pixel_pin = board.D6 # Update to match the number of NeoPixels you have connected pixel_num = 32 pixels = neopixel.NeoPixel(pixel_pin, pixel_num, brightness=0.5, auto_write=False) solid = Solid(pixels, color=PINK) blink = Blink(pixels, speed=0.5, color=JADE) colorcycle = ColorCycle(pixels, speed=0.4, colors=[MAGENTA, ORANGE, TEAL]) chase = Chase(pixels, speed=0.1, color=WHITE, size=3, spacing=6) comet = Comet(pixels, speed=0.01, color=PURPLE, tail_length=10, bounce=True) pulse = Pulse(pixels, speed=0.1, color=AMBER, period=3) animations = AnimationSequence( solid, blink, colorcycle, chase, comet, pulse, advance_interval=5, auto_clear=True, ) while True:
# OR: used a fixed floor # input_floor = 50 # You might want to print the input_floor to help adjust other values. print(input_floor) # Corresponds to sensitivity: lower means more pixels light up with lower sound # Adjust this as you see fit. input_ceiling = input_floor + 100 peak = 0 # Cusomize LED Animations ------------------------------------------------------ rainbow = Rainbow(pixels, speed=0, period=6, name="rainbow", step=2.4) rainbow_chase = RainbowChase(pixels, speed=0.1, size=5, spacing=5, step=5) chase = Chase(pixels, speed=0.2, color=ORANGE, size=2, spacing=6) rainbow_comet = RainbowComet(pixels, speed=0.1, tail_length=30, bounce=True) rainbow_comet2 = RainbowComet(pixels, speed=0.1, tail_length=104, colorwheel_offset=80, bounce=True) rainbow_comet3 = RainbowComet(pixels, speed=0, tail_length=25, colorwheel_offset=80, step=4, bounce=False) strum = RainbowComet(pixels, speed=0.1, tail_length=25,
matrix = Matrix(bit_depth=5) display = matrix.display # 114 colors is the minimum value for all the rainbow animations. 128 use same memory. rect1 = anisha.Arect(16, 1, 30, 30, outline=0x004000, stroke=2, colors=128) group = displayio.Group() group.append(rect1) display.show(group) blink = Blink(rect1, speed=0.5, color=JADE) colorcycle = ColorCycle(rect1, speed=0.4, colors=[MAGENTA, ORANGE]) comet = Comet(rect1, speed=0.01, color=PURPLE, tail_length=10, bounce=True) chase = Chase(rect1, speed=0.1, size=3, spacing=6, color=WHITE) pulse = Pulse(rect1, speed=0.1, period=3, color=AMBER) sparkle = Sparkle(rect1, speed=0.1, color=PURPLE, num_sparkles=10) solid = Solid(rect1, color=JADE) rainbow = Rainbow(rect1, speed=0.1, period=2) sparkle_pulse = SparklePulse(rect1, speed=0.1, period=3, color=JADE) rainbow_comet = RainbowComet(rect1, speed=0.1, tail_length=7, bounce=True) rainbow_chase = RainbowChase(rect1, speed=0.1, size=3, spacing=2, step=8) rainbow_sparkle = RainbowSparkle(rect1, speed=0.1, num_sparkles=15) custom_color_chase = CustomColorChase(rect1, speed=0.1, size=2, spacing=3, colors=[ORANGE, WHITE, JADE]) animations = AnimationSequence(
(53, 72, YELLOW), (77, 96, GREEN), (98, 119, TEAL), (120, 145, BLUE), (150, 173, PURPLE), (180, 200, MAGENTA), ) # Cap touch board setup ------------------------------------------------------ i2c = busio.I2C(board.SCL, board.SDA) mpr121 = adafruit_mpr121.MPR121(i2c) # Demo MODE LED Animations ------------------------------------------------------ rainbow = Rainbow(pixels, speed=0, period=10, name="rainbow", step=1) rainbow_chase = RainbowChase(pixels, speed=0, size=5, spacing=10) chase = Chase(pixels, speed=0.1, color=RED, size=1, spacing=6) rainbow_comet = RainbowComet(pixels, speed=0.01, tail_length=60, bounce=True) # Animation Sequence Playlist -- rearrange to change the order of animations animations = AnimationSequence( rainbow_chase, chase, rainbow_comet, auto_clear=True, auto_reset=True, ) def go_dark(): '''set all pixels to black''' pixels.fill(BLACK)
""" Switch between animations with the Circuit Playground Express/Bluefruit Requires adafruit_led_animation """ from adafruit_circuitplayground import cp import time from adafruit_led_animation.animation.chase import Chase from adafruit_led_animation.animation.comet import Comet from adafruit_led_animation.color import AMBER, JADE chase = Chase(cp.pixels, speed=0.06, size=3, spacing=6, color=AMBER) comet = Comet(cp.pixels, speed=0.02, color=JADE, tail_length=10, bounce=True) anim = comet while True: anim.animate() # lookup buttons to switch between animations buttons = cp.were_pressed if buttons: if 'A' in buttons: anim = chase if 'B' in buttons: anim = comet # the switch sets the brightness if cp.switch: cp.pixels.brightness = 0.2 else: cp.pixels.brightness = 0.8 # for slow animations, sleep a bit, but not too long to read buttons
star1 = anisha.Astar(119, 42, 5, 20, outline=GOLD, colors=16) lights = anisha.Apoints([(105, 125), (100, 170), (75, 180), (50, 180), (80, 135), (60, 145), (95, 100), (80, 110), (119, 85), (158, 110), (143, 100), (178, 145), (158, 135), (188, 180), (163, 180), (138, 170), (133, 125)], size=2, outline=0xFF0000, colors=4) group = displayio.Group(max_size=5, scale=1) group.append(arc1) group.append(arc2) group.append(tree) group.append(star1) group.append(lights) display.show(group) star_pulse = Pulse(star1, speed=0.05, period=6, color=GOLD) tree_sparke = Sparkle(tree, speed=0.3, color=0x00FF00, num_sparkles=20) lights_blink = Chase(lights, speed=1, size=1, spacing=2, color=0xFF0000) animation_group = AnimationGroup(star_pulse, tree_sparke, lights_blink) while True: animation_group.animate()
animations = AnimationSequence( AnimationGroup( Blink(magtag_pixels, speed=0.5, color=blink_color), Blink(strip_pixels, speed=0.5, color=blink_color), ) ) # If white or yellow, do a chase animation in the specified color. if cheerlights_color in ('white', 'yellow'): if cheerlights_color == 'white': chase_color = WHITE elif cheerlights_color == 'yellow': chase_color = YELLOW animations = AnimationSequence( AnimationGroup( Chase(magtag_pixels, speed=0.1, size=2, spacing=1, color=chase_color), Chase(strip_pixels, speed=0.1, size=3, spacing=2, color=chase_color), ) ) timestamp = time.monotonic() except (ValueError, RuntimeError) as e: # Catch any random errors so the code will continue running. print("Some error occured, retrying! -", e) try: # This runs the animations. animations.animate() except NameError: # If Cheerlights adds a color not included above, the code would fail. This allows it to # continue to retry until a valid color comes up. print("There may be a Cheerlights color not included above.")
pixel_wing_horizontal = helper.PixelMap.horizontal_lines( pixels, 8, 4, helper.horizontal_strip_gridmap(8, alternating=False)) comet_h = Comet(pixel_wing_horizontal, speed=0.1, color=PURPLE, tail_length=3, bounce=True) comet_v = Comet(pixel_wing_vertical, speed=0.1, color=AMBER, tail_length=6, bounce=True) chase_h = Chase(pixel_wing_horizontal, speed=0.1, size=3, spacing=6, color=JADE) rainbow_chase_v = RainbowChase(pixel_wing_vertical, speed=0.1, size=3, spacing=2, step=8) rainbow_comet_v = RainbowComet(pixel_wing_vertical, speed=0.1, tail_length=7, bounce=True) rainbow_v = Rainbow(pixel_wing_vertical, speed=0.1, period=2) rainbow_chase_h = RainbowChase(pixel_wing_horizontal, speed=0.1, size=3,
pm2.animate() pm3.animate() pm4.animate() #-------------------- Vorpal animation SIZE = 3 SPACING = 1 # colors V4 = (0, 255, 90, 0) # 4 is tip V3 = (0, 155, 90, 0) # Cyan V2 = (50, 90, 75, 0) V1 = (200, 39, 0, 0) v1 = Chase(pixel_m1, speed=.15, color=V1, size=SIZE, spacing=SPACING, reverse=True) v2 = Chase(pixel_m2, speed=.1, color=V2, size=SIZE, spacing=SPACING, reverse=True) v3 = Chase(pixel_m3, speed=.09, color=V3, size=SIZE, spacing=SPACING, reverse=True) v4 = Chase(pixel_m4,
break # Stop animating powerup.animate() # Cusomize LED Animations ------------------------------------------------------ powerup = RainbowComet(pixel_map[3], speed=0, tail_length=25, bounce=False) rainbow = Rainbow(pixel_map[2], speed=0, period=6, name="rainbow", step=2.4) rainbow_chase = RainbowChase(pixels, speed=0, size=6, spacing=15, step=10) rainbow_chase2 = RainbowChase(pixels, speed=0, size=10, spacing=1, step=18, name="rainbow_chase2") chase = RainbowChase(pixel_map[3], speed=0, size=20, spacing=20) chase2 = Chase(pixels, speed=0.1, color=ORANGE, size=6, spacing=6) rainbow_comet = RainbowComet(pixel_map[2], speed=0, tail_length=200, bounce=True) rainbow_comet2 = RainbowComet(pixels, speed=0, tail_length=104, colorwheel_offset=80, bounce=True) rainbow_comet3 = RainbowComet(pixel_map[2], speed=0, tail_length=80, colorwheel_offset=80, step=4, bounce=False)
pixel_height = 8 num_pixels = pixel_width * pixel_height pixels = adafruit_dotstar.DotStar(board.A1, board.A2, num_pixels, auto_write=False, brightness=0.1) pixel_framebuf = PixelFramebuffer(pixels, pixel_width, pixel_height, rotation=1, alternating=False, reverse_x=True) # Fancy animations from https://learn.adafruit.com/circuitpython-led-animations rainbow_chase = RainbowChase(pixels, speed=0.1, size=3, spacing=6, step=8) chase = Chase(pixels, speed=0.1, color=CYAN, size=3, spacing=6) rainbow_comet = RainbowComet(pixels, speed=0.1, tail_length=5, bounce=True, colorwheel_offset=170) def scroll_framebuf_neg_x(word, color, shift_x, shift_y): pixel_framebuf.fill(0) color_int = int('0x%02x%02x%02x' % color, 16) # negate x so that the word can be shown from left to right pixel_framebuf.text(word, -shift_x, shift_y, color_int) pixel_framebuf.display() time.sleep(SCROLL_TEXT_WAIT)
def Score(text, color, ring_color, repeat): """Show a scrolling text message and animated effects on the eye rings. The messages scrolls left to right, then right to left while the eye rings are animated using the adafruit_led_animation library.""" # Set up a led animation chase sequence for both eyelights chase_left = Chase(left_eye, speed=0.11, color=ring_color, size=8, spacing=4) chase_right = Chase(right_eye, speed=0.07, color=ring_color, size=8, spacing=4) text_area.text = text text_area.color = color x = display.width text_area.x = x width = text_area.bounding_box[2] for _ in range(repeat): # Scroll the text left and animate the eyes while x != -width: x = x - 1 text_area.x = x chase_left.animate() chase_right.animate() time.sleep(0.008) # adjust to change scrolling speed # Scroll the text right and animate the eyes while x != display.width: x = x + 1 text_area.x = x chase_left.animate() chase_right.animate() time.sleep(0.008) # adjust to change scrolling speed
for i in range(5): nextChatter = chatters[random.randint(0, len(chatters) - 1)] while nextChatter == lastChatter: nextChatter = chatters[random.randint(0, len(chatters) - 1)] lastChatter = nextChatter talk(nextChatter) #conversation over, lets see if EVERYONE chimes in... everyone = random.randint(0, 10) if everyone == 0: for j in range(25): twinkle() time.sleep(.05) chase = Chase(pixels, speed=0.1, color=(255, 255, 255), size=1, spacing=5) counter = 0 while True: counter = counter + 1 if counter > 100: animationMode = animationMode + 1 step = 0 counter = 0 if animationMode > 5: animationMode = 1 print("PRESSED! Animation mode ", animationMode) if animationMode == 1:
""" This example animates a theatre chase style animation in white with a repeated 3 LEDs lit up at a spacing of six LEDs off. For QT Py Haxpress and a NeoPixel strip. Update pixel_pin and pixel_num to match your wiring if using a different board or form of NeoPixels. This example will run on SAMD21 (M0) Express boards (such as Circuit Playground Express or QT Py Haxpress), but not on SAMD21 non-Express boards (such as QT Py or Trinket). """ import board import neopixel from adafruit_led_animation.animation.chase import Chase from adafruit_led_animation.color import WHITE # Update to match the pin connected to your NeoPixels pixel_pin = board.A3 # Update to match the number of NeoPixels you have connected pixel_num = 30 pixels = neopixel.NeoPixel(pixel_pin, pixel_num, brightness=0.5, auto_write=False) chase = Chase(pixels, speed=0.1, size=3, spacing=6, color=WHITE) while True: chase.animate()
import neopixel from adafruit_led_animation.animation.chase import Chase from adafruit_led_animation.sequence import AnimationSequence from adafruit_led_animation.color import (RED, GREEN, BLUE) # Update to match the pin connected to your NeoPixels pixel_pin = board.D0 # Update to match the number of NeoPixels you have connected pixel_num = 8 pixels = neopixel.NeoPixel(pixel_pin, pixel_num, brightness=0.8, auto_write=False) RedChase = Chase(pixels, speed=0.4, color=RED, size=1, spacing=8, reverse=True) GreenChase = Chase(pixels, speed=0.4, color=GREEN, size=1, spacing=8, reverse=True) BlueChase = Chase(pixels, speed=0.4, color=BLUE, size=1, spacing=8, reverse=True) animations = AnimationSequence( RedChase,