# 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: anims.color = colorwheel(random.randint(0,255))
pixel_pin = board.D6 pixel_num = 16 pixels = neopixel.NeoPixel(pixel_pin, pixel_num, brightness=.9, auto_write=False) #Setup NeoPixel Grid pixel_wing_vertical = helper.PixelMap.vertical_lines( pixels, 8, 2, helper.horizontal_strip_gridmap(8, alternating=True)) pixel_wing_horizontal = helper.PixelMap.horizontal_lines( pixels, 8, 2, helper.horizontal_strip_gridmap(8, alternating=True)) #Setup LED Animations rainbow = Rainbow(pixels, speed=.001, period=2) pulse = Pulse(pixels, speed=0.1, color=RED, period=3) blink = Blink(pixels, speed=0.5, color=RED) colorcycle = ColorCycle(pixels, speed=0.4, colors=[RED, ORANGE, YELLOW, JADE, BLUE, AQUA, PURPLE]) comet_v = Comet(pixel_wing_vertical, speed=0.05, color=PURPLE, tail_length=6, bounce=True) #Setup the LED Sequences animations = AnimationSequence( rainbow, pulse, comet_v,
enable = DigitalInOut(POWER_PIN) enable.direction = Direction.OUTPUT enable.value = False strip = neopixel.NeoPixel(NEOPIXEL_PIN, NUM_PIXELS, brightness=.5, auto_write=False) strip.fill(0) # NeoPixels off ASAP on startup strip.show() # default NeoPixel color is white COLOR = (255, 255, 255) # NeoPixel animations pulse = Pulse(strip, speed=0.05, color=COLOR, period=3) solid = Solid(strip, color=COLOR) comet = Comet(strip, speed=0.05, color=COLOR, tail_length=40) #audio try: from audiocore import WaveFile except ImportError: from audioio import WaveFile try: from audioio import AudioOut except ImportError: try: from audiopwmio import PWMAudioOut as AudioOut except ImportError:
from adafruit_led_animation.animation.pulse import Pulse from adafruit_led_animation.color import RED # 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 # Update to matchpin connected to button that connect logic high when pushed button_pin = board.D3 pixels = neopixel.NeoPixel(pixel_pin, pixel_num, brightness=0.5, auto_write=False) button = DigitalInOut(button_pin) button.direction = Direction.INPUT button.pull = Pull.UP # Create the animation and freeze it afterwards pulse_animation = Pulse(pixels, speed=0.1, period=1, color=RED) pulse_animation.freeze() while True: pulse_animation.animate() # Pressing the button resumes (or in this case starts) the animation permanently if not button.value: pulse_animation.resume()
# the keyboard object! cc = ConsumerControl(usb_hid.devices) # our array of button objects buttons = [] # make all pin objects, make them inputs w/pullups for pin in buttonpins: button = digitalio.DigitalInOut(pin) button.direction = digitalio.Direction.INPUT button.pull = digitalio.Pull.UP buttons.append(button) animations = AnimationSequence( AnimationGroup( Pulse(pixels, speed=0.05, color=WHITE, period=6), Solid(internal_pixel, color=BLACK), ), ) print("Waiting for button presses") while True: # animate neopixel jewel animations.animate() # check each button for button in buttons: if not button.value: # pressed? i = buttons.index(button) print("Button #%d Pressed" % i)
PINK, AQUA, JADE, AMBER ) # NeoPixel pin pixel_pin = board.A3 # number of NeoPixels pixel_num = 68 # NeoPixels setup pixels = neopixel.NeoPixel(pixel_pin, pixel_num, brightness=0.5, auto_write=False) # animation setup pulse = Pulse(pixels, speed=0.1, color=RED, period=5) # two cap touch pins touch_left = board.A1 touch_right = board.A2 # cap touch setup bolt_left = touchio.TouchIn(touch_left) bolt_right = touchio.TouchIn(touch_right) # NeoPixel colors for animation colors = [RED, YELLOW, ORANGE, GREEN, TEAL, CYAN, BLUE, PURPLE, MAGENTA, GOLD, PINK, AQUA, JADE, AMBER] # variable for color array index c = 0
MODE_SWITCH_TIME = 0.2 # how long to wait for a changed reading # to be consistent to change modes LAUGHING_SPEED = 0.1 # how fast the animation runs USE_AUDIO = True # if you want to disable audio USE_ANIMATION = True # if you want to disable animation if USE_DISTANCE_SENSOR is True: uart = busio.UART(board.TX, board.RX, baudrate=9600) us100 = adafruit_us100.US100(uart) # initialize on board neopixels pixels = neopixel.NeoPixel(board.NEOPIXEL, 4, brightness=1.0, auto_write=False) pixels.fill((0, 0, 0)) pixels.show() pulse = Pulse(pixels, speed=0.3, color=(250, 0, 0)) # turn the board LED off so it does not affect our light sensor supervisor.set_rgb_status_brightness(0) # Light sensor to know when to turn on light = analogio.AnalogIn(board.LIGHT) # speaker enable if the board supports it speaker_enable = digitalio.DigitalInOut(board.SPEAKER_ENABLE) speaker_enable.direction = digitalio.Direction.OUTPUT speaker_enable.value = True # Set up audio audio = AudioOut(board.SPEAKER) mp3 = open("laugh.mp3", "rb")
import board import neopixel from adafruit_led_animation.animation.pulse import Pulse from adafruit_led_animation.animation.rainbow import Rainbow from adafruit_led_animation.animation.rainbowsparkle import RainbowSparkle from adafruit_led_animation.animation.rainbowcomet import RainbowComet from adafruit_led_animation.sequence import AnimationSequence from adafruit_led_animation.color import PURPLE # Update this to match the number of NeoPixel LEDs connected to your board. num_pixels = 124 pixels = neopixel.NeoPixel(board.GP1, num_pixels, auto_write=True) pixels.brightness = 0.2 rainbow = Rainbow(pixels, speed=0.01, period=1) rainbow_sparkle = RainbowSparkle(pixels, speed=0.05, num_sparkles=15) rainbow_comet = RainbowComet(pixels, speed=.01, tail_length=20, bounce=True) pulse = Pulse(pixels, speed=.05, color=PURPLE, period=3) animations = AnimationSequence(pulse, rainbow_sparkle, rainbow_comet, rainbow, advance_interval=5, auto_clear=True, random_order=False) while True: animations.animate()
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()
import board import neopixel from adafruit_led_animation.animation.pulse import Pulse from adafruit_led_animation.color import WHITE # Update to match the pin connected to your NeoPixels pixel_pin = board.NEOPIXEL # Update to match the number of NeoPixels you have connected pixel_num = 10 pixels = neopixel.NeoPixel(pixel_pin, pixel_num, brightness=0.8, auto_write=False) pulse = Pulse(pixels, speed=0.05, color=WHITE, period=5) while True: pulse.animate()
auto_write=False) cp.pixels.brightness = 0.5 animations = AnimationSequence( # Synchronized to 0.5 seconds. Ignores the second animation setting of 3 seconds. AnimationGroup( Sparkle(cp.pixels, 0.1, color.GREEN, num_sparkles=1), Sparkle(strip_pixels, 0.1, color.GREEN, num_sparkles=1), ), AnimationGroup( Blink(cp.pixels, 0.25, color.RED), Blink(strip_pixels, 0.25, color.RED), sync=True, ), # Different speeds AnimationGroup( Comet(cp.pixels, 0.05, color.GREEN, tail_length=5), Comet(strip_pixels, 0.05, color.GREEN, tail_length=5), ), AnimationGroup( Pulse(cp.pixels, 0.05, color.RED, period=3), Pulse(strip_pixels, 0.05, color.RED, period=3), ), advance_interval=4.0, auto_clear=True, auto_reset=True, ) while True: animations.animate()
import board import neopixel from adafruit_led_animation.animation.pulse import Pulse from adafruit_led_animation.color import RED # Update to match the pin connected to your NeoPixels pixel_pin = board.D1 # Update to match the number of NeoPixels you have connected pixel_num = 6 pixels = neopixel.NeoPixel(pixel_pin, pixel_num, brightness=0.5, auto_write=False) pulse = Pulse(pixels, speed=0.01, color=RED, period=1) while True: pulse.animate()
animations = AnimationSequence( AnimationGroup( Comet(magtag_pixels, 0.3, color=comet_color, tail_length=3), Comet(strip_pixels, 0.05, color=comet_color, tail_length=15), ) ) # If green or orange, do a pulse animation in the specified color. if cheerlights_color in ('green', 'orange'): if cheerlights_color == 'green': pulse_color = GREEN elif cheerlights_color == 'orange': pulse_color = ORANGE animations = AnimationSequence( AnimationGroup( Pulse(magtag_pixels, speed=0.1, color=pulse_color, period=3), Pulse(strip_pixels, speed=0.1, color=pulse_color, period=3), ) ) # If oldlace, warmmwhite or magenta, do a sparkle animation in the specified color. if cheerlights_color in ('oldlace', 'warmwhite', 'magenta'): if cheerlights_color in ('oldlace', 'warmwhite'): sparkle_color = OLD_LACE elif cheerlights_color == 'magenta': sparkle_color = MAGENTA animations = AnimationSequence( AnimationGroup( Sparkle(magtag_pixels, speed=0.1, color=sparkle_color, num_sparkles=1), Sparkle(strip_pixels, speed=0.01, color=sparkle_color, num_sparkles=15), )
# 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) colorcycle = ColorCycle(pixels, speed=0.4, colors=[MAGENTA, ORANGE]) 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=AMBER) sparkle = Sparkle(pixels, speed=0.1, color=PURPLE, num_sparkles=10) solid = Solid(pixels, color=JADE) rainbow = Rainbow(pixels, speed=0.1, period=2) sparkle_pulse = SparklePulse(pixels, speed=0.1, period=3, color=JADE) 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]) animations = AnimationSequence( comet,
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( comet,
# or use rings individually: # pixel_ringA = PixelSubset(pixels, 43, 59) # 16 pixel ring # pixel_ringB = PixelSubset(pixels, 59, 75) # 16 pixel ring # pixel_ringC = PixelSubset(pixels, 75, 91) # 16 pixel ring # pixel_ringD = PixelSubset(pixels, 91, 151) # 60 pixel ring # ---BPM--- BPM = 128 BEAT = 60 / BPM # quarter note beat b16TH = BEAT / 4 # 16TH note b64TH = BEAT / 16 # sixty-fourth # ---Anim Setup--- # heal color mode # Pulse 'speed' = smoothness pulse_rings_m0 = Pulse(pixel_ringsAll, speed=0.01, color=ORANGE, period=BEAT) pulse_jewel_m0 = Pulse(pixel_jewel, speed=0.01, color=ORANGE, period=BEAT) comet_stripA_m0 = Comet( pixel_stripA, speed=b64TH, color=ORANGE, tail_length=9, bounce=False ) comet_stripB_m0 = Comet( pixel_stripB, speed=b64TH, color=ORANGE, tail_length=9, bounce=False ) # speed color mode pulse_rings_m1 = Pulse(pixel_ringsAll, speed=0.02, color=RED, period=BEAT / 2) pulse_jewel_m1 = Pulse(pixel_jewel, speed=0.02, color=RED, period=BEAT / 2) comet_stripA_m1 = Comet( pixel_stripA, speed=b64TH, color=RED, tail_length=9, bounce=False ) comet_stripB_m1 = Comet(
pixel_m4 = PixelSubset(pixels, 15, 20) #-------------------- name colors RED = (31, 4, 0, 50) # orangish red for power on confirmation nice and dull BLACK = (0, 0, 0, 0) BLUE = (0, 30, 31, 50) # nice dull cyan blue to indicated BLE connected #-------------------- To be used? # Prophets' Bane P4 = (230, 230, 0, 0) # 4 is tip P3 = (255, 155, 0, 0) # P2 = (255, 90, 0, 0) P1 = (255, 55, 0, 0) PPERIOD = 2 PSPEED = .25 pm1 = Pulse(pixel_m1, speed=PSPEED, period=PPERIOD, color=P1) pm2 = Pulse(pixel_m2, speed=PSPEED, period=PPERIOD, color=P2) pm3 = Pulse(pixel_m3, speed=PSPEED, period=PPERIOD, color=P3) pm4 = Pulse(pixel_m4, speed=PSPEED, period=PPERIOD, color=P4) def prophetsbane(): pm1.animate() pm2.animate() pm3.animate() pm4.animate() #-------------------- Vorpal animation SIZE = 3 SPACING = 1