Solved<
I want many different LEDs to light up in a position intended for them. I use the FastLed library. My approach was to write all colors into an array and then retrieve them in the code below. But I can only retrieve the variable “CRGB::White” from the array, e.g. “CRGB::Red” does not work. If I insert “CRGB::Red” directly into line 29 it works. Nothing happens with the red from the array above.
Can anyone tell me why I can only retrieve white from the array and how I get my 160 different colors into an array so I can retrieve them in different scenarios?
I tried all sorts of things which could cause the syntax or something else to be wrong but it didn’t work.
#include "FastLED.h"
#define NUM_LEDS 160
// Data pin that led data will be written out over
#define DATA_PIN 5
// This is an array of leds. One item for each led in your strip.
CRGB leds[NUM_LEDS];
// This function sets up the ledsand tells the controller about them
void setup() {
// sanity check delay - allows reprogramming if accidently blowing power w/leds
delay(2000);
FastLED.addLeds<WS2812B, DATA_PIN, RGB>(leds, NUM_LEDS);
}
void loop() {
int Array[2];
Array[0] = CRGB::White;
Array[1] = CRGB::Red;
// and so on
for(int whiteLed = 0; whiteLed < NUM_LEDS; whiteLed = whiteLed + 1) {
leds[whiteLed] = Array[0]; // THIS WORKES: leds[whiteLed] = CRGB::Red;
// Show the leds (only one of which is set, from above)
FastLED.show();
// Wait a little bit
delay(50);
/*if number = 1;
number = 0;
if number = 0;
number =1; */
// Turn our current led back to black for the next loop around
leds[whiteLed] = CRGB::Black;
}
}