RGB NeoPixel on CircuitPython: adafruit_led_animation and rainbowio.colorwheel()

YD-ESP32-S3 N16R8 (by VCC-GND Studio) running CircuitPython 10.1.0-beta.1, to control onboard/external 8x RGB LED, using adafruit_led_animation.



cpyS3_led_animation_blink.py
"""
 YD-ESP32-S3 N16R8 (by VCC-GND Studio) running CircuitPython 10.1.0-beta.1 ,
 to control onboard/external 8x RGB LED
 using adafruit_led_animation.
 
 https://coxxect.blogspot.com/2025/12/circuitpython-adafruitledanimation.html
"""
import board
import neopixel

from adafruit_led_animation.animation.blink import Blink
from adafruit_led_animation.color import RED, GREEN, BLUE

# Update to match the pin connected to your NeoPixels
pixel_pin = board.NEOPIXEL
ext_pixel_pin = board.GPIO4
# Update to match the number of NeoPixels you have connected
pixel_num = 1
ext_pixel_num = 8

pixels = neopixel.NeoPixel(pixel_pin, pixel_num, brightness=0.1, auto_write=False)
ext_pixels = neopixel.NeoPixel(ext_pixel_pin, ext_pixel_num, brightness=0.1, auto_write=True)

blink = Blink(pixels, speed=0.5, color=BLUE)
ext_blink = Blink(ext_pixels, speed=0.5, color=BLUE)

while True:
    blink.animate()
    ext_blink.animate()



cpyS3_led_animation_Chase.py
"""
 YD-ESP32-S3 N16R8 (by VCC-GND Studio) running CircuitPython 10.1.0-beta.1 ,
 to control onboard/external 8x RGB LED
 using adafruit_led_animation.
 
 https://coxxect.blogspot.com/2025/12/circuitpython-adafruitledanimation.html
"""
import time
import board
import neopixel

from adafruit_led_animation.animation.chase import Chase
from adafruit_led_animation.color import WHITE,AMBER, JADE, MAGENTA, ORANGE, PURPLE

px_color = [WHITE,AMBER, JADE, MAGENTA, ORANGE, PURPLE]

# Update to match the pin connected to your NeoPixels
pixel_pin = board.NEOPIXEL
ext_pixel_pin = board.GPIO4
# Update to match the number of NeoPixels you have connected
pixel_num = 1
ext_pixel_num = 8

pixels = neopixel.NeoPixel(pixel_pin, pixel_num, brightness=0.1, auto_write=False)
ext_pixels = neopixel.NeoPixel(ext_pixel_pin, ext_pixel_num, brightness=0.1, auto_write=False)

chase = Chase(pixels, speed=0.1, size=3, spacing=6, color=px_color[0])
ext_chase = Chase(ext_pixels, speed=0.1, size=3, spacing=6, color=px_color[0])

color_duration = 3
px_color_index = 0
next_time = time.time() + color_duration

while True:
    chase.animate()
    ext_chase.animate()
    
    if(time.time() >= next_time):
        next_time = time.time() + color_duration
        px_color_index = px_color_index+1
        if px_color_index >= len(px_color):
            px_color_index = 0
            
        chase.color = px_color[px_color_index]
        ext_chase.color = px_color[px_color_index]



cpyS3_led_animation_Comet.py
"""
 YD-ESP32-S3 N16R8 (by VCC-GND Studio) running CircuitPython 10.1.0-beta.1 ,
 to control onboard/external 8x RGB LED
 using adafruit_led_animation.
 
 https://coxxect.blogspot.com/2025/12/circuitpython-adafruitledanimation.html
"""
import time
import board
import neopixel

from adafruit_led_animation.animation.comet import Comet
from adafruit_led_animation.color import RED, GREEN, BLUE

px_color = [RED, GREEN, BLUE]

# Update to match the pin connected to your NeoPixels
pixel_pin = board.NEOPIXEL
ext_pixel_pin = board.GPIO4
# Update to match the number of NeoPixels you have connected
pixel_num = 1
ext_pixel_num = 8

pixels = neopixel.NeoPixel(pixel_pin, pixel_num, brightness=0.1, auto_write=False)
ext_pixels = neopixel.NeoPixel(ext_pixel_pin, ext_pixel_num, brightness=0.1, auto_write=False)

comet = Comet(pixels, speed=0.02, color=px_color[0], tail_length=10, bounce=True)
ext_comet = Comet(ext_pixels, speed=0.02, color=px_color[0], tail_length=10, bounce=True)

color_duration = 3
px_color_index = 0
next_time = time.time() + color_duration

while True:
    comet.animate()
    ext_comet.animate()
    
    if(time.time() >= next_time):
        next_time = time.time() + color_duration
        px_color_index = px_color_index+1
        if px_color_index >= len(px_color):
            px_color_index = 0
            
        comet.color = px_color[px_color_index]
        ext_comet.color = px_color[px_color_index]
    



cpyS3_led_animation_Rainbow.py
"""
 YD-ESP32-S3 N16R8 (by VCC-GND Studio) running CircuitPython 10.1.0-beta.1 ,
 to control onboard/external 8x RGB LED
 using adafruit_led_animation.
 
 https://coxxect.blogspot.com/2025/12/circuitpython-adafruitledanimation.html
"""
import board
import neopixel

from adafruit_led_animation.animation.rainbow import Rainbow
from adafruit_led_animation.animation.rainbowchase import RainbowChase
from adafruit_led_animation.animation.rainbowcomet import RainbowComet
from adafruit_led_animation.animation.rainbowsparkle import RainbowSparkle
from adafruit_led_animation.sequence import AnimationSequence

# Update to match the pin connected to your NeoPixels
pixel_pin = board.NEOPIXEL
ext_pixel_pin = board.GPIO4
# Update to match the number of NeoPixels you have connected
pixel_num = 1
ext_pixel_num = 8

pixels = neopixel.NeoPixel(pixel_pin, pixel_num, brightness=0.1, auto_write=False)
ext_pixels = neopixel.NeoPixel(ext_pixel_pin, ext_pixel_num, brightness=0.1, auto_write=False)

rainbow = Rainbow(pixels, speed=0.1, period=2)
rainbow_chase = RainbowChase(pixels, speed=0.1, size=5, spacing=3)
rainbow_comet = RainbowComet(pixels, speed=0.1, tail_length=7, bounce=True)
rainbow_sparkle = RainbowSparkle(pixels, speed=0.1, num_sparkles=15)

ext_rainbow = Rainbow(ext_pixels, speed=0.1, period=2)
ext_rainbow_chase = RainbowChase(ext_pixels, speed=0.1, size=5, spacing=3)
ext_rainbow_comet = RainbowComet(ext_pixels, speed=0.1, tail_length=7, bounce=True)
ext_rainbow_sparkle = RainbowSparkle(ext_pixels, speed=0.1, num_sparkles=15)

animations = AnimationSequence(
    #rainbow,
    #rainbow_chase,
    rainbow_comet,
    #rainbow_sparkle,
    advance_interval=5,
    auto_clear=True,
)

ext_animations = AnimationSequence(
    #ext_rainbow,
    #ext_rainbow_chase,
    ext_rainbow_comet,
    #ext_rainbow_sparkle,
    advance_interval=5,
    auto_clear=True,
)

while True:
    animations.animate()
    ext_animations.animate()



cpyS3_led_animation_Sparkle.py
"""
 YD-ESP32-S3 N16R8 (by VCC-GND Studio) running CircuitPython 10.1.0-beta.1 ,
 to control onboard/external 8x RGB LED
 using adafruit_led_animation.
 
 https://coxxect.blogspot.com/2025/12/circuitpython-adafruitledanimation.html
"""
import board
import neopixel

from adafruit_led_animation.animation.blink import Blink
from adafruit_led_animation.animation.sparkle import Sparkle
from adafruit_led_animation.animation.sparklepulse import SparklePulse
from adafruit_led_animation.color import AMBER, JADE
from adafruit_led_animation.sequence import AnimationSequence

# Update to match the pin connected to your NeoPixels
pixel_pin = board.NEOPIXEL
ext_pixel_pin = board.GPIO4
# Update to match the number of NeoPixels you have connected
pixel_num = 1   
ext_pixel_num = 8 # Sparkle needs at least 2 pixels

pixels = neopixel.NeoPixel(pixel_pin, pixel_num, brightness=0.1, auto_write=False)
ext_pixels = neopixel.NeoPixel(ext_pixel_pin, ext_pixel_num, brightness=0.1, auto_write=False)

blink = Blink(pixels, speed=0.5, color=JADE)

ext_sparkle = Sparkle(ext_pixels, speed=0.05, color=AMBER, num_sparkles=10)
ext_sparkle_pulse = SparklePulse(ext_pixels, speed=0.05, period=3, color=JADE)

ext_animations = AnimationSequence(
    ext_sparkle,
    ext_sparkle_pulse,
    advance_interval=5,
    auto_clear=True,
)

while True:
    blink.animate()
    ext_animations.animate()





rainbowio.colorwheel() exercise:



cpyS3_rainbowio_colorwheel.py
"""
 YD-ESP32-S3 N16R8 (by VCC-GND Studio) running CircuitPython 10.1.0-beta.1 ,
 to control onboard/external 8x RGB LED
 rainbowio.colorwheel() exercise to display on RGB NeoPixel.
 
 https://coxxect.blogspot.com/2025/12/circuitpython-adafruitledanimation.html
"""
import time
import board
import neopixel
import rainbowio

# Update to match the pin connected to your NeoPixels
pixel_pin = board.NEOPIXEL
ext_pixel_pin = board.GPIO4
# Update to match the number of NeoPixels you have connected
pixel_num = 1
ext_pixel_num = 8

pixels = neopixel.NeoPixel(pixel_pin,pixel_num , brightness=0.1, auto_write=False)
ext_pixels = neopixel.NeoPixel(ext_pixel_pin, ext_pixel_num, brightness=0.1, auto_write=False)

while True:
    for j in range(256):  # 
        for i in range(len(pixels)):
            pixel_index = (i * 256 // len(pixels)) + j
            pixels[i] = rainbowio.colorwheel(pixel_index & 255)
        pixels.show()
        
        for i in range(len(ext_pixels)):
            pixel_index = (i * 256 // len(ext_pixels)) + j
            ext_pixels[i] = rainbowio.colorwheel(pixel_index & 255)
        ext_pixels.show()
        
        time.sleep(0.01)



Comments

Popular posts from this blog

Drive 320x240 ILI9341 SPI TFT using ESP32-S3 (NodeMCU ESP-S3-12K-Kit) using TFT_eSPI library, in Arduino Framework.

480x320 TFT/ILI9488 SPI wih EP32C3 (arduino-esp32) using Arduino_GFX Library