A MicroPython library for P9813 RGB LED drivers.
For example, the Seeed Studio Grove - Chainable RGB LED.
Copy the file to your device, using ampy, webrepl or compiling and deploying. eg.
$ ampy put p9813.py
Basic usage
from machine import Pin
import p9813
pin_clk = Pin(5, Pin.OUT)
pin_data = Pin(4, Pin.OUT)
num_leds = 10
chain = p9813.P9813(pin_clk, pin_data, num_leds)
# set the first LED to red
chain[0] = (255, 0, 0)
# set the second LED to green
chain[1] = (0, 255, 0)
# write data to all LEDs
chain.write()
# make all LEDs red
chain.fill((255,0,0))
chain.write()
# turn off all LEDs
chain.reset()
See p9813_examples.py and examples for more.
- WeMos D1 Mini $4.00 USD
- Grove - Chainable RGB LED $3.90 USD
- Grove Male Jumper Cable $2.90 USD
WeMos D1 Mini | Grove Chainable RGB LED |
---|---|
D1 (GPIO5) | CI (clock) (yellow) |
D2 (GPIO4) | DI (data) (white) |
3V3 (or 5V) | VCC (red) |
G | GND (black) |
If you are chaining multiple LEDs, clock out -> clock in, data out -> data in, eg.
LED1 | LED2 |
---|---|
CO | CI (yellow) |
DO | DI (white) |
VCC | VCC (red) |
GND | GND (black) |
Licensed under the MIT License.