Hi I'm trying to make a 4x4x4 LED Cube and there's a section of my code that maps a 2d array to 3d coordinates and I've been getting an error that says "expected primary-expression before 'aNum'"
the error refers to the line after //section D
here's my code
inline byte getLEDState(byte pattern[4][4][4], byte aNum, byte cNum)
{
byte (aNum, cNum);
// TODO: fill this in to return the value in the pattern array corresponding
// to the anode (+) wire and cathode (-) wire number (aNum and cNum) provided.
//section A
if (byte aNum <= 3 && byte cNum <= 3) {
x = aNum;
y = cNum;
z = 1;
}
//section B
else if (byte aNum >= 4 && byte cNum <= 3) {
x = aNum;
y = cNum - 4;
z = 2;
}
//section C
else if (byte aNum <= 3 && byte cNum >= 4) {
x = aNum;
y = cNum - 4;
z = 3;
}
//section D
else if ( byte aNum >= 4 && byte cNum >= 4) {
x = aNum - 4;
y = cNum - 4;
z = 4;
}
}
return 0;
}
when actually only a snippet of the code was provided.
This, too, is wrong:
byte (aNum, cNum);
There is a byte(...) function but I am only familiar with the one-argument version. Also, I would expect a function named byte to return a result, but any returned result is thrown away.
You don't need to (and can't) declare the type of aNum and cNum everywhere they are used.
Looks like a copy and paste error in Section B.
Looks like an extra '}' before the return statement.
inline byte getLEDState(byte pattern[4][4][4], byte aNum, byte cNum)
{
// TODO: fill this in to return the value in the pattern array corresponding
// to the anode (+) wire and cathode (-) wire number (aNum and cNum) provided.
//section A
if (aNum <= 3 && cNum <= 3) {
x = aNum;
y = cNum;
z = 1;
}
//section B
else if (aNum >= 4 && cNum <= 3) {
x = aNum - 4;
y = cNum;
z = 2;
}
//section C
else if (aNum <= 3 && cNum >= 4) {
x = aNum;
y = cNum - 4;
z = 3;
}
//section D
else if (aNum >= 4 && cNum >= 4) {
x = aNum - 4;
y = cNum - 4;
z = 4;
}
// }
return 0;
}