DEV Community

張旭豐
張旭豐

Posted on

Why Your WS2812B LED Strip Has the Wrong Colors

Why Your WS2812B LED Strip Has the Wrong Colors

You write the code to display red. The strip shows orange. You write green. The strip shows cyan. You write blue. The strip shows purple. You change the color order in the library. Nothing matches.

WS2812B LED strip showing color gradients, properly powered with multiple power injection points
WS2812B color problems - the wrong colors usually mean voltage drop from insufficient power injection along the strip.

The problem is almost certainly power, not code.


How WS2812B Color Works

Each WS2812B LED contains three LEDs: red, green, and blue. The color is controlled by PWM on three separate channels. The LED brightness is proportional to the PWM duty cycle.

The WS2812B uses a specific color encoding: GRB (Green-Red-Blue). Most libraries use GRB internally. If your code passes RGB values and the library expects GRB, the colors are shifted. But even after correcting the byte order, if the colors still look wrong, the problem is power.

When the red LED gets insufficient current, it appears dimmer. Since the strip mixes red, green, and blue to create other colors, any imbalance in the LED currents causes the mixed colors to shift. Red appears orange. Green appears cyan. Blue appears purple.


The Voltage Drop Problem

Each WS2812B LED draws approximately 20mA at full brightness (all three LEDs on, which is white). A 60-LED strip at full white draws 1.2A. A 144-LED strip at full white draws 2.9A.

The problem: voltage drops along the strip length. The strip wire has resistance. At 3A through thin copper traces, the voltage at the end of a 5-meter strip can be 0.5V lower than at the beginning.

The WS2812B needs at least 3.5V to operate correctly. If the voltage at the strip end drops below 3.5V, the LEDs at the end receive insufficient current. The colors shift because the red, green, and blue LEDs have different forward voltages and different current requirements at low voltage.

The fix: inject power at multiple points along the strip. Every 1-2 meters, connect a separate power feed directly to the strip's +5V and GND pins. This eliminates voltage drop.


The Power Supply Problem

A 5V 2A power supply can handle about 100 WS2812B LEDs at full brightness. If you have more than 100 LEDs and one power supply, the supply clips at 2A. The strip tries to draw more current than the supply can provide, the voltage collapses, and the colors shift.

The fix: calculate the total current requirement. Each LED at full white = 60mA total (20mA per color × 3). 60 LEDs = 1.2A. 120 LEDs = 2.4A. Get a power supply rated for at least 1.5x your calculated requirement.

For large installations: use multiple power supplies, each feeding a section of the strip. Connect the data line from one section to the next, but keep the power lines separate.


The Data Signal Quality Problem

The WS2812B uses a single-wire protocol at 800kbps. The signal is sensitive to noise and impedance mismatches.

If the data line is long (more than 2-3 meters) or runs alongside power cables, noise can corrupt the color data. Corrupted data makes random LEDs display random colors, or causes LEDs to repeat previous colors.

The fix: use a level shifter (like the 74HCT245) to boost the data signal from 3.3V to 5V. Use twisted pair wire (like Cat5) for the data line. Keep the data line away from power cables.

For installations longer than 10 meters: use a separate data line driver every 10 meters to regenerate the signal.


The Library Color Order Problem

If you have confirmed the power is correct and the colors are still wrong, the library color order is wrong.

FastLED uses GRB order by default. Adafruit NeoPixel uses GRB. If your code sets CRGB(255, 0, 0) for red and the strip shows green, the library is expecting RGB but the strip is GRB.

Most libraries have a define to change the color order. For FastLED:

#define COLOR_ORDER GRB
Enter fullscreen mode Exit fullscreen mode

For Adafruit NeoPixel:

Adafruit_NeoPixel strip = Adafruit_NeoPixel(60, PIN, NEO_GRB + NEO_KHZ800);
Enter fullscreen mode Exit fullscreen mode

Try all six combinations (RGB, RBG, GRB, GBR, BRG, BGR) until the colors match.


Why the Colors Shift Under Load

The most confusing symptom: the colors look correct when only a few LEDs are on, but shift when more LEDs are on.

This is voltage drop. When only 10 LEDs are on, total current is 200mA. The voltage drop along the strip is minimal. When 60 LEDs are on, current is 1.2A. The voltage drop is significant. At the far end of the strip, the LEDs are undervolted.

The fix is always power injection. No other solution addresses the voltage drop.


Your WS2812B strip is not defective. The colors shift because the LEDs are not receiving sufficient voltage or the current is unbalanced. Inject power every 1-2 meters and the colors become correct.

For reliable WS2812B installations:

5V 10A Power Supply — Handles up to 500 WS2812B LEDs at full brightness. Essential for installations over 100 LEDs. (Amazon)

WS2812B 60 LED/m Strip (1m) — Ready-to-use with adhesive backing. Quality varies by manufacturer - test before large installations. (Amazon)

3.3V to 5V Logic Level Shifter (74HCT245) — Boosts Arduino 3.3V data signal to 5V for long WS2812B runs. Prevents signal corruption. (Amazon)

I earn from qualifying purchases.


Article #021, 2026-04-18. Content Farm pipeline, Run #021.

Top comments (0)