← Back to Articles
Tech Ethics

Arduino FastLED Library

A practical introduction to the FastLED library for addressable LEDs — what it is, how to install it in the Arduino IDE, wiring instructions, and a minimal working sketch to get your first LED strip running.

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

Installing FastLED in Arduino IDE

  1. Open the Arduino IDE
  2. Go to Sketch → Include Library → Manage Libraries…
  3. In the search box type FastLED
  4. 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

💬
Continue the conversation in the forum
Town Square · Community Tool Shed · The Tech Collective · Sustainable Communities · and more
Join the Forum →