All articles

    WS2812B Smart LED Strips: Every LED Its Own Colour

    A guide to WS2812B (NeoPixel) strips: a single data wire, the wiring in a diagram, calculating the current (up to 60 mA per LED) and the power supply with an example, the capacitor and data resistor, the 3.3 V problem with the ESP32, feeding the strip from several points, the FastLED and NeoPixel libraries, simple effects, and the well-known faults and their fixes.

    Updated 5 min read

    An LED strip where each LED is a different colour, with animations, all on one data wire. That's the WS2812B (or NeoPixel). One of the most enjoyable projects, and one of the projects most likely to burn out a power supply if the calculations are wrong.

    Each LED has a small chip, and the colours are sent along a single wire
    Each LED has a small chip, and the colours are sent along a single wire

    How does it work?

    Each LED contains a small chip + 3 LEDs (red, green and blue). The microcontroller sends a sequence of colours:

    • The first LED takes the first colour and passes the rest on to the next, and so on.
    • Only 3 wires: 5V, GND and DIN.
    • Watch for the direction arrow on the strip, and start from the DIN end.

    Each colour takes 24 bits (8 per colour, so 0 to 255), and the signal runs at 800 kilobits per second with very precise timing. That's why the library disables interrupts during sending, which can affect other things that depend on timing (such as receiving an IR remote).

    Wiring

    The power supply feeds the strip directly, the capacitor across the supply terminals, a resistor on the data, and a shared ground
    The power supply feeds the strip directly, the capacitor across the supply terminals, a resistor on the data, and a shared ground

    The most important calculation: current

    Each LED can draw up to about 60 mA at white on full brightness.

    StripApproximate maximum current
    30 LEDs1.8 A
    60 LEDs (one metre)3.6 A
    300 LEDs (5 metres)18 A!
    • Don't run more than a few LEDs from the 5V pin on the Arduino or from USB.
    • A separate 5 V power supply of suitable capacity. See choosing a power supply.
    • Limit the brightness in code (for example 30–50%). The difference to the eye is small, and the difference in current is large.
    • Ground is shared between the supply and the microcontroller. See ground.

    An example: choosing the supply

    A 120-LED strip (2 m at 60 LEDs/m):

    1. The worst case: 120 × 60 mA = 7.2 A (full white, which will rarely happen).
    2. Brightness at 50% in code → about 3.6 A maximum.
    3. Add a 20–30% margin → a 5 V 5 A supply.

    And if the effects are changing colours rather than white, the actual consumption is usually a quarter or a third of the maximum. Work it out quickly with the WS2812 power calculator. And FastLED has setMaxPowerInVoltsAndMilliamps(5, 3000), which lowers the brightness automatically if the current would exceed the limit.

    3 things that protect the strip

    1. A large capacitor (about 1000 µF, 6.3 V or more) across the supply terminals at the start of the strip.
    2. A 300–500 Ω resistor on the data wire close to the first LED.
    3. Connect ground before power, and don't connect the data while the strip is unpowered.

    Why? At the moment of connection, the supply can produce a voltage spike, and the capacitor absorbs it. And the resistor protects the first LED from sharp edges and from current if the strip is unpowered while data is running. The first LED is the most exposed to damage, and when it fails the whole strip stops.

    A long strip: colours fade at the end

    The strip's thin copper causes a voltage drop, so the end of the strip turns yellow or dim. The fix: feed power at several points (every metre or two) with thick wires.

    Not the data: DIN is connected only once, at the start. The extra feed points are 5V and GND only, and the data travels through the strip by itself. And if you feed from more than one power supply, connect their grounds together, but don't connect their positives together.

    With an ESP32 (3.3 V)

    A strip on 5 V may not reliably understand a 3.3 V signal. Sometimes it works and sometimes it flickers randomly. The fix is a fast level shifter chip such as the 74AHCT125.

    An alternative trick: power only the first LED from 5 V through a diode (so it gets about 4.3 V), so 3.3 V is enough for it, and it re-transmits a clean 5 V signal to the rest. It often works, but a level shifter is more reliable.

    The code (FastLED)

    #include <FastLED.h>
    #define NUM 60
    CRGB leds[NUM];
    
    void setup() {
      FastLED.addLeds<WS2812B, 6, GRB>(leds, NUM);
      FastLED.setBrightness(80);
    }
    
    void loop() {
      static uint8_t hue = 0;
      fill_rainbow(leds, NUM, hue++, 7);
      FastLED.show();
      delay(20);
    }

    Or the Adafruit NeoPixel library, which is a little simpler to start with.

    A "running dot" effect

    void loop() {
      static int pos = 0;
      fadeToBlackBy(leds, NUM, 40);   // all the LEDs fade a little
      leds[pos] = CRGB::Cyan;         // one LED lights up
      FastLED.show();
      pos = (pos + 1) % NUM;
      delay(30);
    }

    fadeToBlackBy makes a tail behind the dot. Change the colour and speed as you like.

    GRB or RGB? Most WS2812B strips use GRB order. If you ask for red and get green, change the order in addLeds.

    Well-known faults

    SymptomUsual cause
    Not a single LED lightsThe data enters at the DOUT end (wrong direction) or the ground isn't shared
    The first LED is faulty and the rest are offThe first LED burnt out; cut it off and connect to the second
    Random colours and flickerA 3.3 V signal, a long data wire, or no resistor
    The colours are dim at the end of the stripVoltage drop; feed from several points
    Red comes out greenThe GRB/RGB colour order is wrong
    The Arduino resets on whiteThe supply is weak, or the strip is powered from the Arduino

    FAQ

    What's the difference between the WS2812B, WS2811 and SK6812? The WS2811 is a separate chip that drives 12 V LEDs (one chip per 3 LEDs), so control is less fine-grained but the drop is smaller. The SK6812 is similar to and compatible with the WS2812, and comes in an RGBW version with a real white LED.

    How long can the data wire be? Keep it as short as possible, under a metre if you can. If the distance is longer, put the microcontroller next to the strip, or use a level shifter close to the strip and a resistor on the data.

    Circuits Nerd
    © 2026 Circuits Nerd. All rights reserved.