Control WS2812 LEDs with a Raspberry Pi

Colorful Lights

© Lead Image © Nelli Valova, 123RF.com

© Lead Image © Nelli Valova, 123RF.com

Article from Issue 240/2020
Author(s):

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

SINGLE ISSUES
 
SUBSCRIPTIONS
 
TABLET & SMARTPHONE APPS
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.

  • DIY Scoreboard

    We look at a broadcast video system network that uses Python code to control a video router and check out another program that creates a scoreboard.

  • PhotoFilmStrip

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

  • 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.

  • Arduino CLI

    When programming an Arduino microcontroller board for the first time, most people use the Arduino IDE, a graphical development environment. However, if you prefer the command line, you have a powerful alternative: Arduino CLI.

comments powered by Disqus
Subscribe to our Linux Newsletters
Find Linux and Open Source Jobs
Subscribe to our ADMIN Newsletters

Support Our Work

Linux Magazine content is made possible with support from readers like you. Please consider contributing when you’ve found an article to be beneficial.

Learn More

News