SOLVED: I want many different LEDs to light up in a position intended for

gplus
(Leander Reichstein) #1

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.

Code: https://pastebin.com/M3jNAH0i

(Andrew Tuline) #2

I would be defining that array as CRGB array[2] and NOT int array[2].

I also recommend that you study loads of the readily available (and working) examples.

(Marc Miller) #3

Your code actually seems to work for me. Unless I’m not understanding what you’re asking.

Changing this:
leds[whiteLed] = Array[0];

to this
leds[whiteLed] = Array[1];

will pick the other color. If you make that a variable you can change it on the fly.

Here’s how I might make the custom color array.

(Ken White) #4

@Leander_Reichstein - Look at my following sketch which uses an array of CRGB colors ( see line 21) and the functions that uses colors from that array (see lines 45 and 48 for one example):

For picking a certain color from the many colors that you want to use, you might want to consider using the variable “hue” to set the color as in:

leds[i] = CHSV(hue, 255, 255);

see:

to learn about how to use hue in CHSV(hue, 255, 255) to set a color.

(Leander Reichstein) #5

@marmil Ya, this is the point, it donsn work like this… i will try the oter ideas thx :slight_smile:

(Leander Reichstein) #6

@Andrew_Tuline ou thanks a lot. Studying the other examples is just my method, where i can leran a lot.

(Leander Reichstein) #7

@Ken_White Thnks for the good examples >ThumbUp<