How would i go about creating an array of variables such as.....
int incColor, c0, c1, c2, c3, c4, c5 = 0;
int circleArray[11][9] = { {c5, c5, c5, c5, c5, c5, c5, c5, c5},
{c4, c4, c4, c4, c4, c4, c4, c4, c4},
{c4, c3, c3, c3, c3, c3, c3, c3, c4},
{c4, c3, c2, c2, c2, c2, c2, c3, c4},
{c4, c3, c2, c1, c1, c1, c2, c3, c4},
{c4, c3, c2, c1, c0, c1, c2, c3, c4},
{c4, c3, c2, c1, c1, c1, c2, c3, c4},
{c4, c3, c2, c2, c2, c2, c2, c3, c4},
{c4, c3, c3, c3, c3, c3, c3, c3, c4},
{c4, c4, c4, c4, c4, c4, c4, c4, c4},
{c5, c5, c5, c5, c5, c5, c5, c5, c5} };
So that later on in the code i will be able to address them like this...
void circle(uint16_t mode)
{
switch (mode)
{
case 0:
c0 = random(255);
break;
case 1:
c0 = incColor;
incColor++;
break;
}
for (int x = 0; x < 11; x++)
{
for (int y = 0; y < 9; y++)
{
strip.setPixelColor(x, y, Wheel(circleArray[x][y]));
}
}
c5 = c4;
c4 = c3;
c3 = c2;
c2 = c1;
c1 = c0;
}
The code above doesnt work, i tested both c5 and circleArray[0][0]
c5 = 34
circleArray[0][0] = 0
circleArray[0][0] should be the same as c5 is what i thought but for some reason the value is not getting set...
Does anybody know what im doing wrong here?
~~~~~~~~~~~~~~EDIT~~~~~~~~~~~~~~~~~
Fixed!! thanks to @sj0h for helping me see a much easier solution so now i can turn this...
int c[6] = {0, 0, 0, 0, 0, 0};
int circleArray[11][9] = { {5, 5, 5, 5, 5, 5, 5, 5, 5},
{4, 4, 4, 4, 4, 4, 4, 4, 4},
{4, 3, 3, 3, 3, 3, 3, 3, 4},
{4, 3, 2, 2, 2, 2, 2, 3, 4},
{4, 3, 2, 1, 1, 1, 2, 3, 4},
{4, 3, 2, 1, 0, 1, 2, 3, 4},
{4, 3, 2, 1, 1, 1, 2, 3, 4},
{4, 3, 2, 2, 2, 2, 2, 3, 4},
{4, 3, 3, 3, 3, 3, 3, 3, 4},
{4, 4, 4, 4, 4, 4, 4, 4, 4},
{5, 5, 5, 5, 5, 5, 5, 5, 5} };
void circle(uint16_t mode)
{
switch (mode)
{
case 0:
c[0] = random(255);
break;
case 1:
c[0] = incColor;
incColor++;
break;
}
for (int x = 0; x < 11; x++)
{
for (int y = 0; y < 9; y++)
{
strip.setPixelColor(x, y, Wheel(c[circleArray[x][y]]));
}
}
c[5] = c[4];
c[4] = c[3];
c[3] = c[2];
c[2] = c[1];
c[1] = c[0];
}
into the real life application....