Control WS2812 LEDs with a Raspberry Pi

Colorful Lights

© Lead Image © Nelli Valova,

© Lead Image © Nelli Valova,

Article from Issue 240/2020

Control a matrix of WS2812 LEDs with the Raspberry Pi.

You are probably familiar with the large colored LED strips in many shop windows. Often these light strips use WS2812 RGB LEDs. Ready-made controllers are available, but they usually have a very limited feature set. In this article, I show you how to control a matrix of WS2812 LEDs with the Raspberry Pi.

Power Games

The WS2812 is a programmable RGB LED that is driven by a small controller that has a data byte for each of the three basic colors (red, green, and blue). This arrangement makes it possible to display more than 16 million colors with one LED. Each LED has four connections: two for the 5V power supply and two (DI, data in, and DO, data out) for asynchronous serial data transmission.

The output of one LED can be connected to the input of the next, which theoretically allows any number of WS2812 units to be connected in series. However, at some point, it takes so much time to write the values into the LEDs that they start to flicker. With 1,024 LEDs in series, it is just about possible to supply all the LEDs with data 30 times per second so that no visible flickering occurs.


Use Express-Checkout link below to read the full article (PDF).

Buy Linux Magazine

Get it on Google Play

US / Canada

Get it on Google Play

UK / Australia

Related content

  • Halloween Vending Machine

    A Halloween vending machine frightens visitors, but the braver ones receive a chocolate reward.

  • PhotoFilmStrip

    Easy-to-use PhotoFilmStrip produces high-quality videos and offers plenty of useful features.

  • Matrix

    One tool to rule all online communication: one tool to find them, one tool to bring them all in, and the Matrix to bind them. An open standard for decentralized communication enters the scene.

  • Processing

    The Java application known as Processing can make a computer artist of a non-programmer. We'll show you how to create moving objects and publish a Flash-style applet.

  • Bitwig 1.3

    Bitwig Studio 1.3.5, together with the JACK sound server, gives users the freedom to produce professional-quality tracks.

comments powered by Disqus

Direct Download

Read full article as PDF: