Newbie array woes


Maybe if you posted the code, so we don't have to imagine it?


//load these new array values

Define a new variable with the same name, but limited to the scope until the next }

Two things I see quickly is, that isn't how you read a button. You need to call an digitalRead().

Second, the way you declare the arrays they will only scope to the if statement they are declared in. In other words once the if statement is done the array will be tossed to the bit bucket.

Once you get all your code posted I suspect we may find that a two dimensional array will serve your purpose.


Those KitSet arrays look like separate instances to me, at least on a glance, but then you also a global one. The curly brackets define context, you see. Ok, you have initialized the global array, but you don't have the code that accesses anything but the first item in the array [0].

I would either set the values on the global array individually inside the if, or just pass the local array using a pointer to a function. You'd have int * as the parameter in the function and access an array item just like you would otherwise do outside the function. Then just make sure you don't go over the bounds of the array inside the function because the function wouldn't know how big the array is supposed to be. Then again, you could also pass the size of the array as either an int value for example.

But, I don't know how midi or piezo works and don't know what the array items represent to be able to tell what the code is supposed to look like. You could also have a two-dimensional global array that would define all the kitsets in one place. Then you'd just access individual kitsets by index.