Addressable LED strips — the kind where you control each light individually — are one of the most satisfying components to work with. FastLED is the library that makes them practical on an Arduino.
What Is FastLED?
FastLED is an open-source Arduino library for controlling addressable LEDs (also called "smart LEDs" or "NeoPixels"). It supports most popular LED chipsets, including WS2811, WS2812, WS2812B, and APA102.
Without FastLED, controlling individual LEDs requires sending precisely timed signals at the hardware level — complex enough to fill its own article. FastLED handles all of that for you and gives you a simple API (application programming interface — the set of functions you call to do something) to set colours, run animations, and manage brightness.
What You Need
- An Arduino (Uno, Nano, or similar)
- An addressable LED strip (WS2812B is the most common and easiest to find)
- A 5V power supply capable of at least 60mA per LED (a 30-LED strip needs at least 1.8A)
- Three jumper wires
Installing FastLED in Arduino IDE
- Open the Arduino IDE
- Go to Sketch → Include Library → Manage Libraries…
- In the search box type
FastLED - Click Install on the entry by Daniel Garcia
Wiring
Connect your LED strip to your Arduino:
| LED strip wire | Arduino pin |
|---|---|
| 5V (red) | 5V |
| GND (black or white) | GND |
| Data (green or yellow) | Pin 6 (or any digital pin) |
Note: Do not power more than a few LEDs from the Arduino's 5V pin directly. For a full strip, connect an external 5V supply rated for at least 60mA per LED and share its GND with the Arduino — a 30-LED strip needs at least 1.8A.
Your First Sketch
This sketch turns the first LED red, the second green, and the third blue, then repeats.
#include <FastLED.h>
#define LED_PIN 6 // the data pin your strip connects to
#define NUM_LEDS 30 // total LEDs on your strip
#define BRIGHTNESS 50 // 0 (off) to 255 (full brightness)
CRGB leds[NUM_LEDS]; // CRGB: FastLED's colour type (red, green, blue values). Array holds one colour per LED.
void setup() {
FastLED.addLeds<WS2812B, LED_PIN, GRB>(leds, NUM_LEDS); // GRB = colour channel order for WS2812B strips
FastLED.setBrightness(BRIGHTNESS);
}
void loop() {
leds[0] = CRGB::Red;
leds[1] = CRGB::Green;
leds[2] = CRGB::Blue;
FastLED.show(); // send the colour data to the strip
delay(1000);
FastLED.clear(); // turn all LEDs off
FastLED.show();
delay(1000);
}
FastLED.show() sends the colour values you set in the leds[] array to the physical strip. Nothing lights up until you call it. FastLED.clear() resets every LED in the array to off.
Next Steps
- The companion article Making a Lightshow with Arduino shows how to build multi-colour animations using this foundation.
- The FastLED wiki covers every function in the library with examples.