// only coloring three of nine pixels
#include <FastLED.h>
#define NUMPIX 9
#define DATAPIN 5
#define MAXBRIGHT 255
CRGB led[NUMPIX];
// const int colors [][3] PROGMEM = { // needs read_byte()
const int colors [][3] = {
{255, 0, 0},
{255, 0, 127},
{255, 0, 255},
{255, 127, 255},
{255, 127, 127},
{255, 127, 0},
{255, 255, 0},
{255, 255, 127},
{255, 255, 255},
};
int colorsize = sizeof(colors) / sizeof(colors[0]);
void setup() {
Serial.begin(115200);
FastLED.addLeds<WS2812B, DATAPIN, GRB>(led, NUMPIX);
FastLED.setBrightness(MAXBRIGHT);
FastLED.clear();
FastLED.show();
// printcolors();
showcolors();
}
void showcolors() {
for (int i = 0; i < colorsize; i++) {
for (int j = 0; j < 3; j++) {
led[i] = CRGB(colors[i][0], colors[i][1], colors[i][2]);
FastLED.show();
}
Serial.println();
}
}
void printcolors() {
for (int i = 0; i < colorsize; i++) {
Serial.print("(");
for (int j = 0; j < 3; j++) {
spacepad(colors[i][j]);
Serial.print(colors[i][j]);
if (j != 2)
Serial.print(",");
}
Serial.println(")");
}
}
void loop() {
// empty
}
void spacepad(int val) { // receiving an element in an array
if (val < 100) Serial.print(" ");
if (val < 10) Serial.print(" ");
}