hi all looking a little help i have an 8x8 grid connected in zig zag formation. I want to set each of the 8 rows to a different colour for example led 1-8 red, 9-16, blue ,17-24 pink etc i can get this to work its the next part I’m not sure how to achieve. What i would like to do is have the colors move across the grid so the second row becomes the color of the first the third becomes the second and so on then the first row becomes the color of the 8th row . Any advice on how to achieve this effect would be greatly appreciated thanks.
What code do you have so far? We can give you ideas on how to edit it to achieve that animation if you post it.
Also, this will be a lot easier if you work in x,y rather than trying to figure out the index of led in the strip all the time. Make a function that returns the index of an LED for a given x,y coordinate according to the logic of how you have it hooked up. This will help you avoid the mental gymnastics of trying to do two dimensional graphics in a one dimensional array of LEDs.
Set up each line as an array and manipulate the arrays.
Look at the answers to @Erin_St_Blaine 's question on arrays for some good examples of how to handle
hi thanks for the reply’s i will have a look at arrays.here is what i have so far.
for(int i = 0; i < LED_COUNT; i++) {
leds[i].setHue( thishue);
if (i == 7 )
{
thishue = 31;
}
else if(i == 15)
{
thishue = 62;
}
else if (i == 23)
{
thishue = 91;
}
else if(i == 31)
{
thishue = 123;
}
else if (i == 39)
{
thishue = 154;
}
else if(i == 47)
{
thishue = 185;
}
else if (i == 55)
{
thishue = 216;
}
}
// Show the leds
FastLED.show();
thishue = 0;
}
i’m sure is not the best way to achieve this.
Shifting the rows is fairly simple.
byte rowsize = 8;
for (byte i =NUM_LEDS 1; i >= rowsize; i-) {
leds[i] = leds[i-rowsize];
}
Then, fill your first row with fill_solid() or another for loop.
Nice part of doing it this way is that you can move anything down, doesn’t have to be solid colors. It makes a nice “cascade” effect.