a library for using WS2812b leds (aka neopixels) with Raspberry Pi Pico
Go to file
benevpi acff06b57d adding set_pixel_line which fills a particular section of pixels 2021-01-27 14:37:57 +00:00
examples adding delay 2021-01-25 15:14:23 +00:00
LICENSE
README.md Update README.md 2021-01-27 14:31:03 +00:00
pico_ws2812b.jpg
ws2812b.py adding set_pixel_line which fills a particular section of pixels 2021-01-27 14:37:57 +00:00

README.md

pico_ws2812b

a library for using WS2812b leds (aka neopixels) with Raspberry Pi Pico

neopixels in action

You'll first need to save the ws2812b.py file to your device (for example, open it in Thonny and go file > save as and select MicroPython device. Give it the same name). Once it's there, you can import it into your code.

You create an object with the parameters number of LEDs, state machine ID and GPIO number in that order. so, to create a strip of 10 leds on state machine 0 and GPIO 0, you use:

pixels = ws2812b.ws2812b(10,0,0)

This object has two methods, show() which sends the data to the strip, and set_pixel which sets the colour values for a particular LED. The parameters are LED number, red, green, blue with the colours taking values between 0 and 255.

A simple example is the following typed into the interpreter (warning, fill(...) will light up all the LEDs, so only run this line if you want to turn them all on). For reasons as yet unknown, there seems to sometimes be an issue with the interpreter. I've investigating, but it does seem to always work when run from a file. If the following gives you problems, try loading an file from examples:

>>> import ws2812b
>>> pixels = ws2812b.ws2812b(10,0,0)
>>> pixels.show()
>>> pixels.set_pixel(5,10,0,0)
>>> pixels.show()
>>> pixels.set_pixel(5,0,10,0)
>>> pixels.show()
>>> pixels.fill(20,5,0)
>>> pixels.show()

Pull requests are open if you'd like more features!