int black[4] = {0, 0, 0, 0};
int white[4] = {0, 0, 0, 100};
int red[4] = {100, 0, 0, 0};
int green[4] = {0, 100, 0, 0};
int blue[4] = {0, 0, 100, 0};
int yellow[4] = {40, 95, 0, 0};
int purple[4] = {50, 0, 100, 0};
Can I do this, and then something like this?
int colors[][4] = {black[]}, {white[]};
This doesn’t work, but am I close, or do I have to just list all the values directly in the line where I initiate colors?
I’d like to get them where I can easily loop thru colors, like this:
int colorCount = 7;
for (int i = 0; i < colorCount; i++) {
display(colors*);* i += 1; }
Why do you need an array of arrays? That is not the same as a 2D array. Which do you want? An array of pointers to arrays would be one way. A read 2D array would be another.
int colorCount = 7;
for (int i = 0; i < colorCount; i++) {
display(colors);
i += 1;
}
I’ certain that your code doesn’t look like that. And, now you know why we expect you to use code tags.
On one of my back burner RGB projects, I was thinking about doing something similar, except storing many web colors (R, G, B) in program memory (PROGMEM).... http://arduino.cc/en/Reference/PROGMEM
So, I was thinking of storing a array of R, G, B values, one array for each color (or maybe better to use one array and index each color in multiples of 3), all colors in program memory. Only problem is that I would be changing colors while maintaining the same LED brightness by using HSB color scheme instead of RBB color scheme. That means I'd need a function() to convert the stored color values in RGB to HSB, then convert them back to RGB at the appropriate brightness. The resultant RGB values would then be used to drive the LED output pins.
Looked, but didn't find a RGB library that converts both ways, only found HSB to RGB. I did find formulas, so I should be able to code conversion functions for ways.
Why make each color 10 entries long if you are only using 4?
Why split the color array into a bunch of globals rather than just passing the array?
Why use int when your values fit in a byte?