Green

Once you've finished setting up your Circuit Playground Bluefruit with CircuitPython, you can access the code and necessary libraries by downloading the Project Bundle.

To do this, click on the Download Project Bundle button in the window below. It will download as a zipped folder.

# SPDX-FileCopyrightText: 2021 ladyada for Adafruit Industries
# SPDX-FileCopyrightText: 2021 Kattni Rembor for Adafruit Industries
# SPDX-License-Identifier: MIT

"""
This example shows different ways to use AnimationGroup: syncing four animations across two separate
pixel objects such as the built-in NeoPixels on a Circuit Playground Bluefruit and a NeoPixel Ring.

This example is written for Circuit Playground Bluefruit and a 16-pixel NeoPixel ring connected to
pad A1. It does not work on Circuit Playground Express.
"""
import board
import neopixel
from adafruit_circuitplayground import cp

from adafruit_led_animation.animation.blink import Blink
from adafruit_led_animation.animation.comet import Comet
from adafruit_led_animation.animation.pulse import Pulse
from adafruit_led_animation.animation.sparkle import Sparkle

from adafruit_led_animation.group import AnimationGroup
from adafruit_led_animation.sequence import AnimationSequence

import adafruit_led_animation.color as color

strip_pixels = neopixel.NeoPixel(board.A1, 16, brightness=0.5, 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()

Upload the Code and Libraries to the Circuit Playground Bluefruit

After downloading the Project Bundle, plug your Circuit Playground Bluefruit into the computer USB port. You should see a new flash drive appear in the computer's File Explorer or Finder (depending on your operating system) called CIRCUITPY. Unzip the folder and copy the following items to the Circuit Playground Bluefruit's CIRCUITPY drive. 

  • lib folder
  • code.py

Your Circuit Playground Bluefruit CIRCUITPY drive should look like this after copying the lib folder and code.py file.

This guide was first published on Nov 03, 2021. It was last updated on Oct 27, 2021.

This page (Code) was last updated on Apr 01, 2023.

Text editor powered by tinymce.