Newbie question about arrays

I’m new to Arduino, and haven’t programmed since college, ten years or so ago. I’m working on a project that will involve a two dimensional array - boolean, if it matters. I’ve done a search and didn’t find anything that seemed to answer the question, how do I add data to the array?


If the ‘inner dimention’ aka [this] has 8 or less elements, you could back them in a single byte.

Anyways, you need to either:

//declare & define
boolean arr[SIZE_X][SIZE_Y] = {
  { 1,0,0,1 },
  { 0,0,1,1 },
boolean arr[SIZE_X][SIZE_Y];

//later on, 'add value' or rather set the value at element 0,1 to true
arr[0][1] = true;

Each dimension of the array is 15, at this point, but I think I see from your example what I forgot - the commas. Thank you.


If the dimensions are indeed 15 you might consider using a 1D array of unsigned int's (these are 16 bit wide) and use some boolean math like - - described.

That's an elegant solution, and I might try it - but I'm trying to leave this as scalable as possible, and might wind up needing a larger array. Thank you.