Using Adressable RGB LEDs - WS2812B

Thread Starter

philba

Joined Aug 17, 2017
959
I've been playing with these LEDs and they have become my go-to LED for many microcontroller projects. They are a little tricky to get used to but once you understand them, they are huge win.

Pros:
  • RGB with a single pin
  • very bright
  • inexpensive off ebay/aliexpress (about $0.10 each for individual LEDs)
  • available in a number of assembly formats (individual, strings, arrays)
  • control multiple LEDs with a single pin. Practical limit is in the 1000s.
  • 16M values of color/brightness available
  • each color controllable in 256 brightness steps
  • hand solderable (see cons)
  • works with even low end microcontrollers (8 MHz ATTiny 85, for example)
  • lots of libraries and sample code available
  • arduino compatible
  • code requirements are small.
Cons:
  • SMD (though hand solderable and this is the 21st century)
  • a little big for some indicator LED needs
  • requires microcontroller/cpu
  • protocol requires bit banging
Bit Banging
This is probably the biggest drawback of these LEDs. Basically a 1-wire serial timing based protocol that requires a microcontroller is used. See the diagram
:ws2812b protocol.png
There is no HW in typical microcontrollers that can drive this protocol so a software implementation (aka bit banging) is used. Worse, this requires disabling interrupts during the transfer. But, that is mitigated by several facts:
  • transfer time is fast - approximately 30 uS per LED.
  • no ongoing maintenance - once set, the LED will remain at that setting until changed.
I've built a small demonstration board that includes an Atmel ATTiny 85 and 8 WS2812Bs. It was hand assembled and soldered. and yes, I know I should clean the flux off the board.
P1070023.jpg
Here's the schematic
small schematic.png
As you can see, a single pin is used to control 8 LEDs. SW, BOM and the Eagle PCB files are available on github
I have also uploaded the file to OSHPark and people can order the PCBs from them. The cost is about $9 for 3 boards.

Here's short video of the board in action. The LEDs are so bright that they overwhelm my camera. The colors are much better in person.

A note on the software. It uses Atmel Studio 7.0 which is a free download and must be programmed via the ISP connector. Any programmer that supports an ATTiny85 and ISP should work fine. The ATTiny85 supposedly comes default to 8 MHz but I've gotten several that default to 1 Mhz. It's a simple matter of setting the fuses to get it running at 8 MHz. I'm hoping to put together an Arduino version of the SW as the ATTiny is supported by the Arduino IDE.
 
Last edited:
Top