ADDRESSABLE LED STRIPS

Arduino Uno • WS2812B • NeoPixel

← Back to MigiDigi Index

1 What's an Addressable LED Strip?

Unlike a basic LED strip where every LED shows the same colour, an addressable strip lets you control each LED individually. You can make one red, the next blue, and the one after that green β€” all at the same time. That's what makes chasing patterns, rainbows, and animations possible.

Your strip almost certainly uses the WS2812B chip (often sold as "NeoPixel" strips). Each LED has a tiny controller built in, and they daisy-chain together on a single data wire. That's why there are only three pads at each cut point:

Close-up of a WS2812B LED on a flexible strip showing the controller IC inside the package and the C1 decoupling capacitor

WS2812B close-up β€” you can see the tiny controller IC inside the LED and the C1 decoupling capacitor on the flexible PCB. Three copper traces carry GND, data, and 5V.

GND

Ground. The return path for electricity. Connects to GND on your Arduino.

DI (Data In)

The signal wire. Carries colour instructions to every LED, one after another down the chain.

5V

Power. Each LED draws up to 60mA at full white brightness. This adds up fast!

Look closely at the strip β€” there's usually a tiny arrow printed between each LED showing the direction of data flow. Data goes from DI (Data In) to DO (Data Out). Always connect your Arduino to the DI end.

2 What You Need

PartNotes
Arduino UnoAny genuine or clone will work
WS2812B LED stripAny length β€” start with 8–30 LEDs
330Ξ© resistorGoes on the data line to protect the first LED
470Β΅F capacitor (optional)Across 5V and GND to smooth power spikes
Jumper wires3 wires: data, power, ground
USB cableTo program the Arduino
External 5V power supplyNeeded if using more than ~8 LEDs (see power section)

3 Cutting the Strip

The strip can be cut to any length at the marked copper pads between LEDs. You'll see three exposed copper rectangles labelled GND, DI/DO, and 5V β€” cut right through the middle of these pads with sharp scissors.

βœ‚ cut here β”‚ β”Œβ”€β”€[LED]──┬──┼──┬──[LED]──┐ β”‚ GND β”‚ β”‚ β”‚ GND β”‚ β”‚ DI ──▢ β”‚ β”‚ β”‚ ──▢ DO β”‚ β”‚ 5V β”‚ β”‚ β”‚ 5V β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”Όβ”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚ cut through the copper pads cleanly

Always cut on the copper pads, never between them. If you cut the wrong spot you'll lose a LED and have nowhere to solder wires.

4 Wiring It Up

ARDUINO UNO Pin 6 5V GND 330Ξ© LED STRIP DI 5V GND DI ──▢ ──▢ ──▢ DO 470Β΅F (optional) DATA (Orange) POWER (Red) GROUND (Blue/Black)

Connect Arduino GND to the strip's GND pad.

Connect Arduino 5V to the strip's 5V pad. (For more than ~8 LEDs, use an external 5V supply instead β€” see power section below.)

Connect Arduino Pin 6 through a 330Ξ© resistor to the strip's DI (Data In) pad.

Optional but recommended: Place a 470Β΅F capacitor across the 5V and GND wires near the strip to absorb power spikes when the LEDs first turn on.

Power matters. Each LED draws up to 60mA at full white. A strip of 30 LEDs could pull 1.8A β€” far more than the Arduino's 5V pin can supply (max ~500mA). For strips longer than 8 LEDs, use a separate 5V power supply wired directly to the strip, with GND connected to the Arduino's GND too.

5 Install the Library

We'll use Adafruit's NeoPixel library β€” it works with all WS2812B strips and is the most beginner-friendly option.

Open the Arduino IDE

Go to Sketch β†’ Include Library β†’ Manage Libraries...

Search for "Adafruit NeoPixel"

Click Install on "Adafruit NeoPixel by Adafruit"

An alternative library is FastLED β€” it's more powerful with more built-in effects, but NeoPixel is simpler for getting started. You can always switch later.

6 Your First Sketch β€” All Red

Let's start simple: turn every LED red.

// LED Strip β€” All Red // MigiDigi Tutorial #include <Adafruit_NeoPixel.h> #define LED_PIN 6 // Data wire on pin 6 #define LED_COUNT 8 // Change to your strip length! // Create the strip object Adafruit_NeoPixel strip(LED_COUNT, LED_PIN, NEO_GRB + NEO_KHZ800); void setup() { strip.begin(); // Initialise the strip strip.setBrightness(50); // 0-255 (start low!) // Set every LED to red for (int i = 0; i < LED_COUNT; i++) { strip.setPixelColor(i, strip.Color(255, 0, 0)); } strip.show(); // Push colours to the strip } void loop() { // Nothing here yet! }

Key concepts:

strip.Color(R, G, B)

Sets a colour using Red, Green, Blue values from 0 to 255. (255, 0, 0) = red, (0, 255, 0) = green, (0, 0, 255) = blue.

strip.setPixelColor(n, colour)

Sets LED number n to a colour. LEDs are numbered from 0.

strip.show()

Pushes all your colour changes to the strip. Nothing visible changes until you call this!

7 Sketch 2 β€” Rainbow Chase

Now let's make something move. This sketch sends a rainbow cycling down the strip.

// LED Strip β€” Rainbow Chase // MigiDigi Tutorial #include <Adafruit_NeoPixel.h> #define LED_PIN 6 #define LED_COUNT 8 Adafruit_NeoPixel strip(LED_COUNT, LED_PIN, NEO_GRB + NEO_KHZ800); void setup() { strip.begin(); strip.setBrightness(50); strip.show(); } void loop() { rainbowChase(50); // 50ms between frames } void rainbowChase(int wait) { for (long offset = 0; offset < 65536; offset += 512) { for (int i = 0; i < LED_COUNT; i++) { // Spread the rainbow evenly across the strip int hue = offset + (i * 65536 / LED_COUNT); strip.setPixelColor(i, strip.ColorHSV(hue)); } strip.show(); delay(wait); } }

ColorHSV(hue) is brilliant for rainbows. The hue value goes from 0 to 65535 β€” covering the full colour wheel. No need to manually calculate RGB values.

8 Sketch 3 β€” Knight Rider (Larson Scanner)

The classic back-and-forth sweep β€” a single bright LED bouncing from end to end with a fading trail.

// LED Strip β€” Larson Scanner (Knight Rider) // MigiDigi Tutorial #include <Adafruit_NeoPixel.h> #define LED_PIN 6 #define LED_COUNT 8 Adafruit_NeoPixel strip(LED_COUNT, LED_PIN, NEO_GRB + NEO_KHZ800); void setup() { strip.begin(); strip.setBrightness(50); } void loop() { // Sweep forward for (int i = 0; i < LED_COUNT; i++) { strip.clear(); strip.setPixelColor(i, strip.Color(255, 0, 0)); // Fading trail if (i > 0) strip.setPixelColor(i-1, strip.Color(80, 0, 0)); if (i > 1) strip.setPixelColor(i-2, strip.Color(20, 0, 0)); strip.show(); delay(80); } // Sweep back for (int i = LED_COUNT - 1; i >= 0; i--) { strip.clear(); strip.setPixelColor(i, strip.Color(255, 0, 0)); if (i < LED_COUNT-1) strip.setPixelColor(i+1, strip.Color(80, 0, 0)); if (i < LED_COUNT-2) strip.setPixelColor(i+2, strip.Color(20, 0, 0)); strip.show(); delay(80); } }

9 Power β€” The Maths

This is where most beginners get caught out. Each WS2812B LED can draw up to 60mA at full white brightness. Here's a quick reference:

LEDsMax CurrentPower Source
1–8~0.5AArduino USB power is fine
9–30~1.8ASeparate 5V 2A supply
30–60~3.6ASeparate 5V 4A supply
60–150~9ASeparate 5V 10A supply + power injection

Always connect GND between the Arduino and the external power supply. Without a common ground, the data signal won't work and you could damage the Arduino.

In practice, you'll rarely hit maximum draw because you won't run every LED at full white. Using setBrightness(50) cuts current by roughly 80%. But always size your power supply for the worst case.

10 Challenges β€” Try These!

Once you've got the basics working, have a go at these:

🟒 Beginner: Traffic Light

Use 3 LEDs. Make them cycle through red β†’ amber β†’ green β†’ red, like a real traffic light. Add realistic timing (red longest, amber shortest).

πŸ”΅ Intermediate: Button Colour Picker

Add a push button. Each press cycles the whole strip through a list of colours: red β†’ green β†’ blue β†’ white β†’ off β†’ red…

🟑 Intermediate: Cylon with Potentiometer

Wire up a potentiometer to control the speed of the Knight Rider sweep. Map the analog reading (0–1023) to delay values (20–200ms).

πŸ”΄ Advanced: VU Meter

Connect a sound sensor or microphone module. Map the sound level to the number of lit LEDs β€” quiet = few LEDs (green), loud = all LEDs (red at the top). Like a classic audio level meter.

🟣 Advanced: Festive Twinkle

Randomly pick LEDs and fade them in and out at different speeds, like fairy lights. Use millis() instead of delay() so multiple LEDs twinkle independently.

11 Troubleshooting

Nothing lights up

Check the data direction arrow on the strip β€” you might be wired to the DO (output) end. Also check your LED_COUNT and LED_PIN values match your wiring.

First LED is the wrong colour or flickers

Add the 330Ξ© resistor on the data line if you haven't already. This protects the first LED's data input from voltage spikes.

LEDs flicker or show random colours

Usually a power issue. Add the 470Β΅F capacitor across 5V and GND. If using lots of LEDs, switch to an external power supply.

Only some LEDs work

Check LED_COUNT is set to the right number. Also check for cold solder joints if you've soldered the strip β€” data is serial, so one bad connection breaks everything after it.

Colours look wrong (e.g. red when you set green)

Some strips use a different colour order (RGB vs GRB). Try changing NEO_GRB to NEO_RGB in the strip constructor.