Hello,
When attempting to compile code I'm met with this error (shown below) and I'm unsure on how to fix it. I'm generally quite new to arduino and have only done a couple of projects so am also open to criticism.
Here is the error:
error: incompatible types in assignment of 'int' to 'int [8]'
neighbourArray[targetY, targetX] = total;
___________________________________________ ^~~~~
exit status 1
Compilation error: incompatible types in assignment of 'int' to 'int [8]'
Here is the code in question:
void loop() {
int rowNum = 8;
int columnNum = 8;
bool cellArray[][8] = {
{ false, true, false, false, false, false, false, false },
{ false, false, false, false, false, false, false, false },
{ false, false, false, false, false, false, false, false },
{ false, false, false, false, false, false, false, false },
{ false, false, false, false, false, false, false, false },
{ false, false, false, false, false, false, false, false },
{ false, false, false, false, false, false, false, false },
{ false, false, false, false, false, false, false, false }
};
int neighbourArray[][8] = {
{ 0, 0, 0, 0, 0, 0, 0, 0 },
{ 0, 0, 0, 0, 0, 0, 0, 0 },
{ 0, 0, 0, 0, 0, 0, 0, 0 },
{ 0, 0, 0, 0, 0, 0, 0, 0 },
{ 0, 0, 0, 0, 0, 0, 0, 0 },
{ 0, 0, 0, 0, 0, 0, 0, 0 },
{ 0, 0, 0, 0, 0, 0, 0, 0 },
{ 0, 0, 0, 0, 0, 0, 0, 0 }
};
int Gloop = 0;
while (Gloop == 0) {
int total;
for (int targetY = 0; targetY < rowNum; targetY++) {
for (int targetX = 0; targetX < columnNum; targetX++) {
total = 0;
for (int neighbourY = targetY - 1; neighbourY < targetY + 2; neighbourY++) {
for (int neighbourX = targetX - 1; neighbourX < targetX + 2; neighbourX++) {
if (neighbourY < rowNum & neighbourX < columnNum & neighbourY >= 0 & neighbourX >= 0) {
total += cellArray[neighbourY, neighbourX];
}
}
}
if (cellArray[targetY, targetX] == true) {
neighbourArray[targetY, targetX] = total - 1;
} else {
neighbourArray[targetY, targetX] = total;
}
}
}
}
}
This section of code should work completley seperatley from the main program as it uses seperate and new variables compared to the rest of the program, so i have taken it out (the error still occurs here)
I am using true and false for "cellArray" because the dot matrix and the library im using needs it to be able to work.
Thank you