Choosing an RGB LED

Find out which RGB LED is correct for the project you have in mind with this guide.

Evan Rust
4 years agoLights / Displays / Art / Badges

In recent years there has been an explosion of new RGB LEDs and corresponding communication protocols. They have enabled countless creative projects, including large matrices, interactive games, and persistence of vision displays. But knowing which LED to use and when can be difficult. Some LEDs are "dumb," and can use many GPIO pins and ample current. Other ones have integrated controllers, and thus only need one or two pins for communication, but they are often slower to respond to changes in color and need more complex programming.

Dumb LEDs

These LEDs are the most basic kind. Just like a single LED, these differ by having not just one internal diode, but three or even four, along with a common pin, which is referred to as common cathode or common anode.

By having a common power pin or common ground pin connected, along with three or four control wires, different color combinations can be created by using PWM. This has the advantage of being very easy to set up, since all someone has to do is put a few analogWrite()'s into their code. The primary downside is the sheer amount of pins required, but there is also another one- unless you want to use a single pin per LED lead, then all of the LEDs will be the same color (except when using a multiplexer). This is fine for simple ambient lighting or a status light, but for anything more complex, such as a matrix, then an LED with an internal controller is better.

Smart LEDs

Smart LEDs are dumb LEDs with special integrated circuitry. They have extremely small internal integrated circuits (ICs) that decode and encode signals from external pins, and then they light up their onboard "dumb" LED accordingly.

This lets each LED have independent control over the color and brightness while only using a few pins for communication. They're great for large displays and complex lighting effects where individual control is a necessity.

One and Two Wire Communication

When discussing communication protocols, it's important to know how many wires are used and what purposes they serve. One-wire interfaces are clock-independent (asynchronous), so they are very timing dependent. Since there is no second clock wire, any deviations in delays on the data line can cause the data to be read incorrectly, thus corrupting it. Information is cascaded down the chain of LEDs, as the previous LED passes on the remaining data to the rest of the LEDs.

On the other hand, two-wire interfaces have an additional pin for a clock signal, so the timing can be easily changed, and therefore the speed at which the LEDs can update.

NeoPixels/WS2812b

This variety of individually addressable LEDs is the most ubiquitous. They are normally soldered to long strips of flexible PCBs or put onto rigid PCBs in various shapes. Each LED has 4 pins- one for ground, one for 5v, one for data in, and one for data out. One wire is used to send data along the chain of LEDs, and its speed is 500KHz, and the signal can only be off by +/- 150 nanoseconds at most before the data becomes invalid. Sending a color to a single LED takes at least 30 microseconds, which might not seem like much time on its own, but when scaled up to hundreds or thousands of LEDs, this latency becomes quite noticeable. Each LED gets a packet of 24 bits, which correspond to the color they are supposed to be. The LED then removes those bits and passes on the rest down the chain via its data out pin.

WS2812b LEDs are fairly cheap and versatile, but they are relatively slow and are extremely timing-dependent, which means boards such as the Raspberry Pi will not work well with them. The WS2812b has many libraries, tutorials, and writeups, making them great for starting out.

WS2801

The WS2801 differs from the WS2812b in that it is a standalone IC that can drive an external RGB LED. It is controlled over a two-wire serial interface and can output a constant current between 5 and 150mA. This also lets it control larger LEDs that require more voltage, and can therefore be brighter.

Since it uses a synchronous interface, it can send and receive data at 2MHz for up to 6 meters, making it great for high-performance and high-powered applications. The primary downside to using this in projects is higher costs. The WS2801 is an IC, so LED strips not only require the driver itself, but also an LED. Also, when placed on a PCB, the driver, with its numerous pins, and also the RGB LED can take up much more space than other LED varieties.

APA102

The final RGB LED on this list is the APA201. It combines the best qualities of the WS2812b LED with the WS2801 driver. It features built-in brightness adjustment, a synchronous interface, an integrated LED in a very small package, and a higher refresh rate.

This makes it nearly perfect for use with microprocessors running an operating system, such as the Raspberry Pi, where strict timing on a general GPIO pin might not be possible. Some people have been able to control a strip of these LEDs at nearly 4MHz, which far surpasses what the WS2812b is able to do. Finally, this variety of LED can understand a lower logic level, such as 3.3v, whereas the WS2812b cannot. This property eliminates the need for a logic level shifter when used with boards such as the Teensy 4.0 and Raspberry Pi. The primary downside to using the APA102 LED is the cost, as the package and IC are more complex than the WS2812b.

Conclusion

RGB LEDs are amazing at providing an abundance of light at a low cost while not consuming much power. When designing a project that utilizes them, consider your needs and requirements. If it just needs to display a few simple colors on one to four LEDs, stick with a discrete "dumb" variety. But if you need something that can be individually controlled and display a wide variety of colors, go with something like a WS2812b or APA102. Although more expensive, the APA102 is better for interfacing with SoCs and other 3.3v microcontrollers. The WS2801 should normally be used to control more powerful LEDs independently with clock and data signals.

Evan Rust
IoT, web, and embedded systems enthusiast. Contact me for product reviews or custom project requests.
Latest articles
Sponsored articles
Related articles
Latest articles
Read more
Related articles