Referencing arrays - do I need to use pointers?

I have some arrays defining the RGB values for some LEDs (these are only example values below) :

const int scheme1[30] = {

  • 4095,0,0,4095,0,0,4095,0,0,4095,0,0,4095,0,0,4095,0,0,4095,0,0,4095,0,0,4095,0,0,4095,0,0};*
    const int scheme2[30] = {
  • 0,4095,66,0,4095,0,0,4095,0,0,4095,0,0,4095,0,0,4095,0,0,4095,0,0,4095,0,0,4095,0,0,4095,0};*

etc. up to scheme10

These work fine if I reference the specific array manually, but I want be able to cycle the scheme I am currently using with a button press eg:

[button press] [if currentscheme=scheme1 then currentscheme=scheme2 .. if currentscheme=scheme10 then currentscheme=scheme1 etc.]

So I can then reference a value in the array:

currentscheme[value x] so in the instance where I am currently using scheme2 (because the button was pressed once since reset), and x was 3, the value returned would be 66 in this example.

I am not sure how to do this, because I cant seem to store the name of the array as a variable (currentscheme=scheme1 etc.) Is this correct?

I THINK an alternative may be to use pointers, but I am having trouble expanding on this - can anyone help? Maybe I am going about this in the wrong way.

How about a two-dimensional array?

And if you are storing a lot of data you may be getting low on RAM - in which case you should look into the FLASH library.

// first declare currentscheme as a pointer to an integer

int * currentscheme;

// then you can set values of currentscheme like this
// remembering that the name of an array used without brackets is a pointer to the first element of the array

currentscheme = (int *)scheme1;

//and do this
if (currentscheme == (int *) scheme1)
currentscheme = (int *)scheme2;

// and this kind of thing (assuming x is declared as an int)

x = currentscheme[3];

// just watch out that you don't overflow the array bounds
// personally I wouldn't bother declaring the arrays as const int (just int)
// then you don't need all the casting.

etc etc