or more information on Pixels (with a colour chart at the bottom of the page), see:
#include "FastLED.h" // FastLED library.
#if FASTLED_VERSION < 3001000 // This guarantees the person will have to use FastLED 3.1
#error "Requires FastLED 3.1 or later; check github for latest code.".
#endif
// Fixed definitions cannot change on the fly.
#define LED_DT 12 // Data pin to connect to the strip.
#define LED_CK 11 // Clock pin used by WS2801 or APA102.
#define COLOR_ORDER BGR // Use BGR for APA102 and GRB for WS2812.
#define LED_TYPE APA102 // Or WS2812. Don't forget to change the FastLED.addLeds line as well.
#define NUM_LEDS 20 // Number of LED's.
// Initialize changeable global variables.
uint8_t max_bright = 64; // Overall brightness definition. It can be changed on the fly, i.e. with a potentiometer.
struct CRGB leds[NUM_LEDS]; // Initialize our LED array.
void setup () {
delay(3000); // If things go bad, you can shutdown before the LED's start drawing power.
Serial.begin(57600); // Get the serial port running for debugging.
// FastLED.addLeds<LED_TYPE, LED_DT, COLOR_ORDER>(leds, NUM_LEDS); // Use this for WS2812B
FastLED.addLeds<LED_TYPE, LED_DT, LED_CK, COLOR_ORDER>(leds, NUM_LEDS); // Use this for WS2801 or APA102
FastLED.setBrightness(max_bright);
} // setup()
void loop() {
leds[0] = CRGB::Red;
FastLED.show();
} // loop()
leds[0] = CRGB(50,0,200); // OR leds[i].setRGB(50,0,200);
leds[i] = 0x3F048E;
leds[i] = leds[j];
leds[i] += CHSV(mythue, mysat, mybright); // Add to an existing colour with CHSV value.
leds[i].r = 128;
leds[i] = random(); // Returns a 'long' value. Do not use 'int' values for RGB.