MicroPythonRaspberry Pi PicoExact chip

MicroPython: NeoPixel ring

A colour runs round a 16-pixel ring on GP16, with the neopixel module.

MicroPython: NeoPixel ring in Argynix Lab

The code

main.pyPython
# A colour runs round a 16-pixel ring on GP16. The neopixel module sends the bits with
# WS2812 timing through machine.bitstream, which counts the CPU's cycles.
from machine import Pin
from neopixel import NeoPixel
import time

ring = NeoPixel(Pin(16), 16)
hue = 0
while True:
    for i in range(16):
        c = (hue + i * 16) % 256
        ring[i] = (c, 255 - c, (c * 3) % 256) if i % 4 == 0 else (0, 0, 0)
    ring.write()
    hue = (hue + 8) % 256
    time.sleep(0.1)