(15, 30, ORANGE), (31, 52, AMBER), (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():
84, 85, 86, 87, 88, 89, 90, 91 ], individual_pixels=True) # Rings Only PIXEL_MAP_RINGS = PixelMap(PIXELS, [ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83 ], individual_pixels=True) # LED ANIMATIONS ----------------------------------------------------------- RAINBOW = Rainbow(PIXEL_MAP_RINGS, speed=0.01, period=10, step=3) CP_RAINBOW = Rainbow(cp.pixels, speed=0.01, period=10, step=3) CRYSTAL_COMET = Comet(PIXEL_MAP_CRYSTALS, speed=SPEED, tail_length=8, color=PURPLE, bounce=True) DARK_RINGS = Solid(PIXELS, color=BLACK) DARK_CPB = Solid(cp.pixels, color=BLACK) DARK = AnimationGroup( DARK_RINGS, DARK_CPB, ) # Animations Playlist, reorder as desired. AnimationGroups play at same time ANIMATIONS = AnimationSequence( AnimationGroup( CRYSTAL_COMET, RAINBOW,
pixels.show() time.sleep(0.02) pixels.fill(BLACK) pixels.show() time.sleep(0.005) pixels.fill(TILT_COLOR) pixels.show() time.sleep(0.01) pixels.fill(BLACK) pixels.show() time.sleep(0.03) # Cusomize LED Animations ------------------------------------------------------ powerup = RainbowComet(pixel_map[3], speed=0, tail_length=25, bounce=False) rainbow = Rainbow(pixel_map[4], speed=0, period=6, name="rainbow", step=2.4) rainbow_chase = RainbowChase(pixel_map[3], speed=0, size=3, spacing=15, step=10) rainbow_chase2 = RainbowChase(pixel_map[2], speed=0, size=10, spacing=1, step=18) chase = Chase(pixel_map[1], speed=0.1, color=RED, size=1, spacing=6) rainbow_comet = RainbowComet(pixel_map[2], speed=0, tail_length=80, bounce=True)
# 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, blink, rainbow_sparkle, chase,
def switch_colors(anim): anim.color = colorwheel(random.randint(0, 255)) comet = Comet(pixels, speed=0.03, color=(0, 255, 255), tail_length=6, bounce=False) comet1 = Comet(pixels, speed=0.05, color=(255, 255, 0), tail_length=6, bounce=True) rainbow = Rainbow(pixels, speed=0.1, period=2, step=10) animations = AnimationSequence(comet, comet1, rainbow, advance_interval=6) comet.add_cycle_complete_receiver(switch_colors) comet.notify_cycles = 2 ble = BLERadio() uart_service = UARTService() advertisement = ProvideServicesAdvertisement(uart_service) while True: #advertise when not connected ble.start_advertising(advertisement) while not ble.connected: animations.animate() ble.stop_advertising()
current_speed = 4 # Set your number of pixels here pixel_num = 20 pixel_pin = board.A1 pixels = neopixel.NeoPixel(pixel_pin, pixel_num, brightness=1, auto_write=False) # Animation Setup rainbow = Rainbow(pixels, speed=speeds[current_speed], period=2, name="rainbow", step=3) sparkle = Sparkle(pixels, speed=speeds[current_speed], color=WHITE, name="sparkle") rainbowfade = RainbowFade(pixels, speed=speeds[current_speed], name="rainbowfade") solid = Solid(pixels, color=colorwheel(0), name="solid") # Animation Sequence Playlist -- rearrange to change the order of animations animations = AnimationSequence( rainbow,
#Setup NeoPixels 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,
pixel_num = 9 pixels = neopixel.NeoPixel(pixel_pin, pixel_num, brightness=0.3, auto_write=False) # variable for number of pixels in the pixelmap helper num = 1 # pixel map helper # allows you to light each candle up one by one # begins with one being lit (num) candles = helper.PixelMap.horizontal_lines( pixels, num, 1, helper.horizontal_strip_gridmap(pixel_num, alternating=False) ) # rainbow animation rainbow = Rainbow(candles, speed=0.1, period=5) animations = AnimationSequence(rainbow) # turn on center candle pixels[4] = AMBER pixels.show() while True: # if only one candle is lit, don't rewrite center neopixel if num == 1: pass # otherwise write data to center neopixel else: pixels[4] = AMBER
def draw(self): # draw the animation ''' fades the entire strip through the whole spectrum ''' self.color = colorwheel(self._color_index + 1) self._color_index = (self._color_index + 1) % 256 self.fill(self.color) # ANIMATION DEFINITIONS -- # create as many animations as you'd like and define their attributes here. # They can be a single line or a group of animations - the groups will play # at the same time, overlaid on top of each other. readingLight = Solid(pixels, color=0xFF7D13) #warm white color HEX code brightWhite = Solid(pixels, color=(150, 150, 150)) rainbow = Rainbow(pixels, speed=0.1, period=10, step=0.5) rainbowfade = RainbowFade(pixels, speed=0.4, name="rainbowfade") powerup = RainbowComet(pixels, speed=0, tail_length=50, bounce=False) off = Solid(pixels, color=BLACK) #startup animation will play just once startup = AnimateOnce(powerup) #starrynight and fire are animation groups with layered effects. starrynight = AnimationGroup( SparklePulse(pixels, speed=0.01, color=(0, 0, 150), period=1), Comet(pixels, speed=0, tail_length=8, color=(150, 150, 150), bounce=False), ) fire = AnimationGroup( Comet(pixels, speed=0, tail_length=1, color=BLACK),
# 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, blink, rainbow_sparkle, chase,
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()
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, spacing=3) animations = AnimationSequence( rainbow_v, comet_h, rainbow_comet_v, chase_h, rainbow_chase_v, comet_v, rainbow_chase_h, advance_interval=5, )