array "has not been declared"?

Hello all! I'm new here... I've been using Arduinos for a little while and I'm doing some summer research with a project that's based on an Arduino. I'm using a Mega (well, two actually) to create an imaging device using LEDs as emitters and receivers of light (project wiki at led-brdf.wikispaces.com).

I'm writing some code for the device but I'm encountering the most frustrating errors with an array. See, I'm controlling a variety of LEDs with the Arduino. Visualize 32 LEDs. For the first sequence, I want to turn LED #1 on, and sense using LEDs 2-32. For the second sequence, I want to turn LED 2 on, and sense using LEDs 1, 3-32. My plan was to use an array to initialize the LED sequences - I could have one column per sensing sequence, which interfaces very well with some code I've been using for the actual sensing part of the routine. The arrays look like this:

  byte LEDcathodes[15][16] = {A1, A0, A0, A0, A0, A0, A0, A0, A0, A0, A0, A0, A0, A0, A0, A0,
                             A2, A2, A1, A1, A1, A1, A1, A1, A1, A1, A1, A1, A1, A1, A1, A1,
                             A3, A3, A3, A2, A2, A2, A2, A2, A2, A2, A2, A2, A2, A2, A2, A2,
                             A4, A4, A4, A4, A3, A3, A3, A3, A3, A3, A3, A3, A3, A3, A3, A3,
                             A5, A5, A5, A5, A5, A4, A4, A4, A4, A4, A4, A4, A4, A4, A4, A4,
                             A6, A6, A6, A6, A6, A6, A5, A5, A5, A5, A5, A5, A5, A5, A5, A5,
                             A7, A7, A7, A7, A7, A7, A7, A6, A6, A6, A6, A6, A6, A6, A6, A6,
                             A8, A8, A8, A8, A8, A8, A8, A8, A7, A7, A7, A7, A7, A7, A7, A7,
                             A9, A9, A9, A9, A9, A9, A9, A9, A9, A8, A8, A8, A8, A8, A8, A8,
                             A10, A10, A10, A10, A10, A10, A10, A10, A10, A10, A9, A9, A9, A9, A9, A9,
                             A11, A11, A11, A11, A11, A11, A11, A11, A11, A11, A11, A10, A10, A10, A10, A10,
                             A12, A12, A12, A12, A12, A12, A12, A12, A12, A12, A12, A12, A11, A11, A11, A11,
                             A13, A13, A13, A13, A13, A13, A13, A13, A13, A13, A13, A13, A13, A12, A12, A12,
                             A14, A14, A14, A14, A14, A14, A14, A14, A14, A14, A14, A14, A14, A14, A13, A13,
                             A15, A15, A15, A15, A15, A15, A15, A15,A15, A15, A15, A15, A15, A15, A15, A14}; //this array is the firing sequence, by column.
int LEDanodes[15][16] = {5, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
                            7, 7, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
                            9, 9, 9, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
                            11, 11, 11, 11, 9, 9, 9, 9,	9, 9, 9, 9, 9, 9, 9, 9,
                            13, 13, 13, 13, 13, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11,
                            21, 21, 21, 21, 21, 21, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
                            23, 23, 23, 23, 23, 23, 23, 21, 21, 21, 21, 21, 21, 21, 21, 21,
                            25, 25, 25, 25, 25, 25, 25, 25, 23, 23, 23, 23, 23, 23, 23, 23,
                            27, 27, 27, 27, 27, 27, 27, 27, 27, 25, 25, 25, 25, 25, 25, 25,
                            29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 27, 27, 27, 27, 27, 27,
                            31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 29, 29, 29, 29, 29,
                            33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 31, 31, 31, 31,
                            35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 33, 33, 33,
                            37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 35, 35,
                            39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 37}; // this is the anode firing sequence, corresponding to LEDcathodes.

Here, each column is a separate lighting sequence - I can pass a given column to the sensing function and not worry about interfering with the LED that is acting as a normal emitter. The problem I'm running into with these is that when I compile the entire program (these arrays plus the actual sensing code), I get an error from the compiler that says that "LEDcathodes has not been declared". I find this strange, because I can compile both of these arrays on their own (just in an empty sketch with void setup and loop) without any problems. After three hours of trying to investigate why this is happening, I figured I'd come and ask some people who actually knew about programming (I've been teaching myself C++ all week to do this). Might anybody know why the compiler is giving this error, or any possible workarounds? I've been working with it all morning and I haven't accomplished much.

Thanks,

Kevin

Post the entire sketch, then it'll be much easier for folks to help you

The sketch can be downloaded below; the LED sensing portion is based on some code that Mike Cook posted on his site a few years back (found here: http://www.thebox.myzen.co.uk/Workshop/LED_Sensing_files/Sensor_LEDs.pde)

The sketch itself is below, as a .pde. Any other useful/constructive comments about the code would be helpful too... as I said, I'm newer to programming than I'd like to be, and anything that you could offer to help improve my abilities as a programmer would be greatly appreciated.

-Kevin

BRDF_dome_revised_nonfunctional_C.pde (8.22 KB)

I think it's this line

int SenseRoutine(int emitter, int counter, byte LEDcathodes[][16], int column)

There was no type so the compiler thought it was a class which of course had not been declared.

Also, AFIAK these are not a valid lines (or if they are I haven't seen that syntax before)

for(int emitter=0, int column=0; emitter<=16, column<=16; emitter++, column++){

SenseRoutine(emitter, 10, LEDcathodes[][16], column);


Rob

Nice spotting on that one, Graynomad - I forgot to declare the array type when it was called by the function. Yes, there are a variety of things wrong with this code right now (working on fixing them one at a time). I figured I should start at the beginning of the compile errors that I don't understand.

Unfortunately that change still gives me the same error, though :~

ah! I spoke too soon! The addition of that into the code fixed the main problem I was having.

Graynomad, I took your advice and changed some of the parameters for my function when it's called. That was also a source of problems for me. I'll just stick with constant values (1, 2, 3, etc) for the rest of the code, I guess.

I'm still getting some sass from the compiler - only one thing, though. In line 67, it says that is expecting a primary-expression before 'LEDcathodes'. I find that strange because there is now a primary expression (byte) there. It's likely that in my inexperience I have misinterpreted this result. Any thoughts?

BRDF_dome_revised_nonfunctional_D.pde (8.14 KB)

Since you know the dimensions of your arrays, you should use

byte array2d[15][16]={{16 numbers}, {another 16 numbers},...};

The compiler may have allowed your way of one list {all numbers} though.

Hey, that's a slick way of inputting numbers into the array! Thanks. I solved the other issue with calling the function, too - according to some sample code I've seen, I don't have to input the array size when I call the function. So I can call SenseRoutine(a, b, LEDcathode, c), if I have a prototype function at the top of the code. I hope this works.