How to Control LED Strips With Arduino – Part 3: Individually Addressable LEDs (WS2812B)
by dziubym in Circuits > Arduino
284 Views, 4 Favorites, 0 Comments
How to Control LED Strips With Arduino – Part 3: Individually Addressable LEDs (WS2812B)

Welcome to Part 3 of my LED control series with Arduino! In this final installment, we’ll explore WS2812B individually addressable LED strips — the kind that let you control every single LED separately with vibrant, precise colors and animations.
Unlike the analog RGB strips from Part 2, WS2812B strips require only one data pin and give you full control over brightness, color, and effects at the pixel level.
We’ll cover:
- How WS2812B LEDs work
- How to wire and power them
- How to use the FastLED library
- How to animate them using the HSV color model
- And how to scale your projects from a simple strip to full LED matrices
🎥 Watch the full video tutorial here:
👉 https://youtu.be/YKSFRmvA9A0
📚 Missed the earlier parts?
- 💡 Part 1 – Single Color LED Strips https://youtu.be/ms8_rbJWyoo
- 🌈 Part 2 – RGB LED Strips https://youtu.be/PEiDzPVk-9g
Each part builds on the last, so feel free to check them out if you're just joining now!
Supplies
To follow along with this project, you'll need:
Core Components:
- Arduino Uno, Nano, or Mega (Uno or Nano recommended for beginners)
- WS2812B LED strip or WS2812B matrix
- (5V version, individually addressable)
- 220Ω resistor (for data line protection)
- Breadboard and jumper wires
- External 5V power supply (2A or higher, depending on LED count)
- Barrel jack or screw terminal adapter
️ Optional/Recommended:
- 3D-printed LED diffuser panel (improves color blending)
- FastLED or NeoPixel library (we’ll use FastLED)
- Power distribution board (for large matrices or multiple strips)
- Logic level shifter (if your board runs at 3.3V)
Meet the WS2812B – What Makes It Special?


The WS2812B LED strip looks similar to RGB LED strips, but it’s far more powerful and simpler to use. Instead of controlling the whole strip at once, you can control each LED individually using just four connections:
- VCC – 5V power
- GND – Ground
- DIN – Data in
- DOUT – Data out
Each LED has a built-in driver chip, which means all the PWM and color mixing is handled internally. You just send digital color data from your Arduino, and each LED takes care of its own brightness and color output.
📌 Key Features:
- Only one Arduino pin needed for control
- Integrated capacitor (100nF) on each segment for power stability
- Directional data flow – you must connect to the end marked DIN
- No PWM required – the library handles everything via serial data
Wiring a WS2812B Strip to an Arduino



Wiring WS2812B LEDs is simpler than RGB strips — just one signal pin and two power lines — but getting it wrong can damage your LEDs or Arduino. Let’s do it right.
🔐 Best Practice Add-ons
To protect your LEDs and Arduino:
- 220Ω resistor between Arduino pin and DIN → prevents voltage spikes
- 1000µF capacitor across VCC and GND at strip input → stabilizes power
- Always power off before connecting/disconnecting the strip
✅ Example for 10 LEDs and Arduino Nano:
- VCC → Nano 5V
- GND → Nano GND
- DIN → D6 with a 220Ω resistor inline
- Optional: 1000µF cap between VCC and GND
Choosing a Library – FastLED Vs. Adafruit NeoPixel



Before you go too far, let’s address a common question:
Which library should you use? FastLED or Adafruit_NeoPixel?
Both libraries support WS2812B and other addressable LEDs — and both are excellent. The right choice depends on your needs.
🧪 A Simple Comparison: Light Up a 7-LED Strip
Let's light up WS2812B LED strips using two sketches using two different libraries:
📚 Code Comparison:
⚡ FastLED Version
✅ What this does:
- Lights up all 7 LEDs in bright red using the CRGB(255, 0, 0) color assignment.
- FastLED.show() pushes the updated color data to the strip.
💡 Adafruit NeoPixel Version
✅ What this does:
- Lights up all 7 LEDs in green using strip.Color(0, 255, 0) for each pixel.
- strip.show() updates the strip with the new color values.
🎯 Why I Prefer FastLED
While both libraries are solid, I personally prefer FastLED because:
- It supports the HSV color model, which makes color transitions smoother and more intuitive
- It allows you to define LED colors in multiple ways
- It uses the CRGB object to manage color, which is both powerful and readable
🔍 The CRGB Object
FastLED defines each LED as a CRGB object — a structure with three components: red, green, and blue.
Here’s how it’s defined internally:
📷 [Image: Visual breakdown of CRGB structure]
This lets you set colors very flexibly — using RGB values, HSV, named colors, or even hexadecimal notation.
🎨 Examples: Setting an LED to Magenta
Let’s say you want to make LED 0 display magenta — here are several valid ways using FastLED:
🔴 Using RGB values directly:
🧠 Using predefined color constants:
🌈 Using HSV (hue-saturation-value):
🟪 Using hexadecimal notation:
All of these methods result in the same color, but each approach shines in different use cases — for example:
- HSV is great for animations and gradients
- Named colors are fast and readable
- RGB is standard and universal
- Hex codes match CSS/web color formats
This flexibility is one of the key reasons I favor FastLED for projects where expressive color control matters.
Creating a Flowing Color Animation Using HSV and CHSV



This example brings together a few powerful FastLED features — the CHSV color model, timed animations using millis(), and array manipulation — to create a flowing color stream across your LED strip or matrix.
💻 Full Code Overview
🔍 Code Highlights
- millis() and timeStep control the update rate without using delay()
- leds[i] = leds[i - 1]; shifts the whole array — like moving pixels to the right
- CHSV(startColor, 255, 255) gives you full-saturation hues
- startColor += colorStep; cycles through hue values over time
🎉 Result
Your LED strip flows continuously with animated color, seamlessly transitioning through the spectrum. It’s dynamic, bright, and visually impressive — ideal for everything from desk lighting to art installations.
✨ This effect already looks fantastic on a loosely tangled LED strip — the overlapping lights blend and scatter color beautifully.
But for an even more polished look, place your strip inside LED channels with diffusion panels. These soften the light, blur the transitions, and give the animation a smooth, professional finish that’s perfect for ambient lighting, under-cabinet effects, or decorative builds.
From Strip to Matrix – Unlocking Visual Possibilities




One of the best things about using addressable LEDs is that you’re not limited to a straight line. By arranging your LED strip into a matrix layout, you can transform it into a low-resolution display capable of showing images, animations, and scrolling text.
A matrix is simply a 2D arrangement — like 13 columns by 5 rows — that turns your strip into a grid of pixels.
✨ Why Use a Matrix?
With a matrix, you can:
- Light up specific areas or corners of your display
- Animate shapes that move across rows and columns
- Create immersive effects like waves, comets, or pixel-based fire
- Even build custom light-up signs or visual meters
💡 In my case, I reused the same LED strip from earlier steps, but arranged it as a matrix. The simple comet animation — which already looked good in a linear channel — suddenly came alive as a fluid, colorful wave across the grid.
📺 Watch it in action:
See the matrix effects in my full video tutorial:
Project Recap + Support + What’s Next

You've now completed Part 3 of my LED strip series — and it’s the most powerful yet. You learned how to use individually addressable LEDs (WS2812B) to create rich, flowing animations using just a single data wire and the FastLED library.
✅ What You’ve Achieved
- Explored FastLED vs. NeoPixel libraries
- Learned why HSV is great for animation
- Created smooth, timed color flow across your strip
- Saw how a simple animation becomes next-level when run on a matrix layout
- Discovered that LED strips can do far more than just blink — they can paint light in motion
Whether you're lighting up your desk, building a display, or just having fun experimenting, you now have the tools to create something vibrant and custom.
☕ Support My Work
If you enjoyed this project and want to support more tutorials like it, consider buying me a coffee on Ko-fi:
👉 https://ko-fi.com/mariosideas
Your support helps me keep making free, high-quality content for makers like you. Thank you!
📺 Explore More on YouTube
Want more Arduino projects, LED tutorials, and experiments?
Check out my channel — I’ve got over 100 videos on all kinds of maker topics.
👉 https://www.youtube.com/channel/UC_YUPxLXSRu_4_zCO27kRww/
There’s always something new to learn, build, and light up.
Thanks for following along — and I’ll see you in the next build! ✨