Controlling a
WS2812B RGB LED Matrix
A few years ago, I was sent a WS2812B matrix display board that has 16x16 chips on it, so it has a total of 256 RGB LEDs. I was asked if I could create a library for it in Positron8 for an inexpensive device, so I set about writing the code and found that I enjoyed seeing it operate so much, I created several demo programs for it, and embellished the library code's functionality so it operates just like a low resolution coloured OLED display with graphics and text capabilities. The board used can be seen below:
The library can be used on any Microchip PIC18F device, as long as it has enough RAM for the display's buffer. But most new PIC18F devices have sufficient RAM, and the display only requires a single pin to operate!
Below is the circuit for the display in the Proteus/Isis simulator, and it is running the plasma demo. See how simple the circuit is? The newer PIC18F devices have an internal oscillator that is capable of running at 64MHz, so there is not need for an external resonator or crystal at all, and the single pin for the matrix display can be any of the device's pins because the code does not use any special peripherals, just good old bit-bashing created by a fast and efficient compiler. i.e. Positron8. With some slight library code changes, the matrix can also be extended to larger or wider using more matrix boards joined together serially, for a scrolling mesage board, or a very large colour graphic LCD.
The Positron8 library code and the demos, and the Proteus/Isis simulator files can be downloaded from here:
Positron8 WS2812B Matrix Library and Demos
If you build the above circuit with the matrix board, make sure you have a 5 Volt Power Supply Unit that is capable of 4 Amps, or over, because when all the LEDs are illuminated fully, the display draws a lot of current, as I found out to my surprise.
Below are a few videos of the demo programs I created, working within the Proteus/Isis simulator. The Isis simulator makes a good job of the WS2812B devices, but they do not show the colours as they appear on the real chips, which are nice and bright and clear. Also, the simulation is slower than the real thing, but, hey, it works nicely and shows what is possible with such a simple circuit and Positron8 BASIC code that is easy to follow and use: