1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

3-Wire PWM


This will explain how various PWM led types are controlled and setup.

If you want to use PWM, please blacklist your audio kernel modul.
For more information please look here.

WS2812B chipset

The "ws2812b" driver only works for the Raspberry Pi 1 (A and B model).
The newly merged "ws281x" driver works for Raspberry Pi 1,2 and 3


You can use the special driver for Ws2812b to run compatible leds, the device-config for the original led device should look like this:

  "device" :
     "name"  : "MyPi",
     "type"  : "ws2812b",
     "colorOrder" : "rgb"
The device-config for the NEW led device that support RPi 1,2,3 should look like this:
  "device" :
     "name"  : "MyPi",
     "type"  : "ws281x",
     "colorOrder" : "grb",
     "leds"  : 107
Additional device parameters

In addition to "colorOrder" and "leds", the "ws281x" device has the following parameters (listed here with their defaults):
     "gpio"  : 18,
     "dmanum"  : 5,
     "freq"  : 800000,
     "pwmchannel" : 0,
The RPi 2 and 3 both have three pins capable of PWM, BCM 18 (default, channel 0), BCM 12 (channel 0) and BCM 13 (channel 1). All three pins have been verified to work with WS2812B LEDs and with the ws281x driver. However, both PWM channels are used by the Pi's on-board analog audio, so you have the problem outlined below no matter which pin you choose.

Hardware setup

Connect the data line of the leds to the pin 12 (GPIO 18) of your raspberry pi, most people put a resistor (R* in the graphic) (100Ohm) between the leds and the pi for less ringing.
HINT:If you use higher resistor values, the reaction speed of your leds looks delayed!

This simple wiring isn't guaranteed to work for everyone. The ws2812b specifications state that the logic "high" signal needs to be > 0.7*VCC which is 3.5v. The Pi's GPIO pins will only output 3.3v so this will be close enough for some users, but is not guaranteed. To do it properly, you should use a level shifter on the data line or drop the LED strip's VCC to 4.7V.

Known problems

These drivers uses the same hardware (PWM channels) as the analog audio out of the RPi, they **can not** work at the same time since the share the same output data line! If you don't direct the audio to the HDMI port or otherwise disable the analog audio, you'll get random nonsense on your LEDs.

For a reason that hasn't been nailed down yet, if you use an OSMC or RetroPie image (straight Jessie and Jessie-Lite don't yet exhibit this behavior), then this driver will only work if the HDMI port is connected when the Pi boots.

If you want to use a ws2812 without tying up a USB port you may want to consider a SPI to ws2812 converter.bThere are a couple of these written by penfold42 published here:

There seems to be a problem using this driver with Raspbian on Raspberry Pi 3 and Raspberry Pi Zero W (reported here: https://github.com/beyondscreen/node-rpi-ws281x-native/issues/61). To fix it, set the dmanum to 10 in the driver options.

More information

All RPi pin configurations, depending on your version:


Pin Configuration of the RPi / RPi2 40 pin header with nice printout (40 pin 'Hat'):


General information about WS2812B wiring


More info at: https://github.com/tvdzwan/hyperion/issues/6

This page has been seen 43,689 times.