Skip to content

mhed89/WS2812-RP2350-Library

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 

Repository files navigation

WS2812 PIO Driver for RP2350

MicroPython PIO-based WS2812 (NeoPixel) driver for the Raspberry Pi Pico 2 (RP2350).

Why not neopixel?

The built-in neopixel module in MicroPython relies on bit-banging - toggling a GPIO pin in a timed loop from software. This worked fine on the RP2040, but on the RP2350 the faster clock speed and different pipeline behavior break the sensitive timing that WS2812 LEDs require (~800 kHz signal with tight T0H/T1H tolerances). The result is garbled colors or LEDs that don't light up at all.

This library solves the problem by using the PIO (Programmable I/O) hardware on the RP2350. PIO runs a small state machine independently of the CPU, producing cycle-accurate output regardless of CPU speed or MicroPython overhead. The timing is guaranteed by hardware, not software.

Usage

from ws2812_rp2350 import WS2812

strip = WS2812(pin=0, num_leds=10, brightness=0.2)

strip.set(0, 255, 0, 0)  # LED 0 -> Red
strip.fill(0, 255, 0)     # All LEDs -> Green
strip.write()              # Push to strip
strip.clear()              # All off

API

Method Description
WS2812(pin, num_leds, brightness=1.0, sm_id=0) Init strip on given GPIO pin
set(i, r, g, b) Set LED i to an RGB color
fill(r, g, b) Set all LEDs to one color
write() Push buffer to the strip
clear() Turn off all LEDs

License

Beerware - If you find this useful and we meet someday, you can buy me a beer.

About

MicroPython PIO-based WS2812 (NeoPixel) driver for the Raspberry Pi Pico 2 (RP2350). Lightweight library with per-pixel and fill control, adjustable brightness, and efficient state machine timing. No external dependencies.

Topics

Resources

Stars

Watchers

Forks

Contributors

Languages