Raspberry Pi - Raspbian

True color RGB LED HAT

True color RGB LED HAT

WS2812B is an LED controller of which the control circuit and the RGB chip are integrated in a package of 5050 components.

  • https://www.waveshare.com/wiki/RGB_LED_HAT
  • https://github.com/jgarff/rpi_ws281x
  • https://github.com/rpi-ws281x/rpi-ws281x-python

Install

pip install rpi_ws281x

Python

import time

from neopixel import *

LED_COUNT      = 32      # Number of LED pixels.
LED_PIN        = 18      # GPIO pin connected to the pixels (must support PWM!).
LED_FREQ_HZ    = 800000  # LED signal frequency in hertz (usually 800khz)
LED_DMA        = 5       # DMA channel to use for generating signal (try 5)
LED_INVERT     = False   # True to invert the signal (when using NPN transistor level shift)
LED_BRIGHTNESS = 255     # Set to 0 for darkest and 255 for brightest

strip = Adafruit_NeoPixel(LED_COUNT, LED_PIN, LED_FREQ_HZ, LED_DMA, LED_INVERT, LED_BRIGHTNESS)


strip.begin()
strip.show()

# https://github.com/jgarff/rpi_ws281x/blob/master/python/neopixel.py
# https://github.com/jgarff/rpi_ws281x/tree/master/python/examples