Hello,
I need to fill an array with the bitWrite function
but the compiler keeps reporting type and operand errors.
I think the problem comes from the fact that array[x][x] is a pointer to int instead of an int...
int16_t array[4][4][128];
int i, j;
byte flow;
void setup()
{
for (i=0;i<4;i++)
for (j=0;j<4;j++)
for (flow=0;flow<128;flow++)
bitWrite(array[i][j], flow, 0);
}
How can I compile the operation ?
Thank you
int16_t array[4][4][128];
128 * 4 * 4 * 2 = 4096 bytes. Which Arduino are you using?
bitWrite(array[i][j], flow, 0);
So, you want to write bits 0 to 127 of this array of 128 ints? Not going to happen.
Which Arduino are you using?
I am currently using an Uno for testing some code,
will buy a Mega when it's time to build.
So, you want to write bits 0 to 127 of this array of 128 ints? Not going to happen.
Indeed...
I meant to declare an array of bits, instead of an array of ints, which takes less place.
But, if I replace "int16_t" by "byte" in the declaration of the array, I still have an error occuring :
" invalid operands of types 'byte [128]' and 'long unsigned int' to binary 'operator|' ",
but I never declared an unsigned long int !
128 * 4 * 4 * 2 = 4096 bytes
This array is meant to send midi data to a drum machine. Maybe I was seeing too big
when deciding to work with that much data. 64 bytes should be enough...
I am currently using an Uno for testing some code,
will buy a Mega when it's time to build.
That is the exact opposite of what you should be doing.
You should develop code on a system with lots of resource and then cut this down when you know exactly how much resource you need.
But, if I replace "int16_t" by "byte" in the declaration of the array, I still have an error occuring :
This is because you declared the variable array as having three dimensions and yet when you used it you only gave it two indices.
128 * 4 * 4 * 2 = 4096 bytes
This array is meant to send midi data to a drum machine. Maybe I was seeing too big
when deciding to work with that much data. 64 bytes should be enough...
As you have not picked up the hint an Uno as 2K of ram for ALL its needs, your array trys to use all of that, even the you could build the program it could not run.
Mark
That is the exact opposite of what you should be doing.
You should develop code on a system with lots of resource and then cut this down when you know exactly how much resource you need.
I totally agree with that, except that I already need more pins than what the Uno has.
Maybe I could regroup some functions under the same buttons but every button already has more than one function.
This is because you declared the variable array as having three dimensions and yet when you used it you only gave it two indices.
I think I finally understand what you meant ! I thought I needed to declare strings of bytes
and didn't understand the second argument of bitWrite, which was talking about a numeric value.
so I guess I need to declare an array of 4 long unsigned int, that way:
uint16_t array[4][4];
void setup() {
for (int i=0;i<4;i++)
for (int j=0;j<4;j++)
for (int count=0;count<16;count++)
bitWrite(array[i][j], count, 0);
}
Is that right ?
As you have not picked up the hint
ahahah 
I didn't fully pick up the hint indeed. I knew that was a lot but didn't know it was THAT MUCH.
The weird thing is that I thought I had seen much more in other programs than mine,
but they were writing to EEPROM (that I don't know much about) so that must be the reason why 
Is that right
Well it looks right, but I have no idea why you want to write all zeros one zero at a time.
Just make it equal to zero and it will do all 16 bits at once.
It was more for knowing how to use it ! 
Thank you for your support
and your time