skip navigational linksPJRC
Shopping Cart Checkout Shipping Cost Download Website
Home MP3 Player 8051 Tools All Projects PJRC Store Site Map
You are here: Teensy Teensyduino Libraries FastSPI_LED

PJRC Store
Teensy 3.6, $29.25
Teensy 3.5, $24.25
Teensy 3.2, $19.80
Teensy LC, $11.65
Teensy 2.0, $16.00
Teensy++ 2.0, $24.00
Teensy
Main Page
Hardware
Getting Started
How-To Tips
Code Library
Projects
Teensyduino
Reference

FastLED Library

The FastLED library, by Daniel Garcia, allows you to many types of LED strips.

Download: Included with the Teensyduino Installer
Latest Developments on Github

Hardware Requirements

TODO: pinout table, Clock/Data: Teensy 2.0 is 1/2; Teensy++ 2.0 is 21/22; Teensy 3.0 is 13/11

Example Program

#include <FastLED.h>

#define NUM_LEDS 18

// Sometimes chipsets wire in a backwards sort of way
struct CRGB { unsigned char b; unsigned char r; unsigned char g; };
// struct CRGB { unsigned char r; unsigned char g; unsigned char b; };
struct CRGB *leds;

void setup()
{
  FastLED.setLeds(NUM_LEDS);
  FastLED.setChipset(CFastLED::SPI_LPD8806);
  FastLED.init();
  FastLED.start();
  leds = (struct CRGB*)FastLED.getRGBData(); 
}

void loop() { 
  // Fade in/fade out
  for(int j = 0; j < 3; j++ ) { 
    memset(leds, 0, NUM_LEDS * 3);
    for(int k = 0; k < 256; k++) { 
      for(int i = 0; i < NUM_LEDS; i++ ) {
        switch(j) { 
          case 0: leds[i].r = k; break;
          case 1: leds[i].g = k; break;
          case 2: leds[i].b = k; break;
        }
      }
      FastLED.show();
      delay(3);
    }
    delay(1000000);
    for(int k = 255; k >= 0; k--) { 
      for(int i = 0; i < NUM_LEDS; i++ ) {
        switch(j) { 
          case 0: leds[i].r = k; break;
          case 1: leds[i].g = k; break;
          case 2: leds[i].b = k; break;
        }
      }
      FastLED.show();
      delay(3);
    }
  }
}