I have been working non-stop for a week now trying to figure out how to do the following with my xmas lights setup like the attached image shows.
I would like to fade from black to red on column1 row1, which is on Pin9, Pixel#49-40 then onto column2 row1, which is on Pin10, Pixel#0-9 fading from black to green, and then column3 row1, which is on Pin11, Pixel#0-9, fading from black to red and then have it move down to Column3, row2, which is on Pin11, Pixel#10-19 having it fade from black to green, and then move again to Column2, row2, Pin10, Pixel#10-19, and so on.
Sorry for the Newbie questions, as I have looked everywhere and tried to set pixels individually with no luck :-(.
I am using 3 - NeoPixel WS2812B strips that are 50 Pixels in length.
Here’s a rough draft of how you would address your pixels - assuming you could overlay an X/Y grid on top of your three columns (with y=0, x=0 being the upper left corner of your drawing and y=4, x=29 being the lower right):
int XY(uint8_t x, uint8_t y) {
// determine what column we’re in
uint16_t base = 0;
if(x >= 10) base += NUM_LEDS_PER_STRIP;
if(x >= 20) base += NUM_LEDS_PER_STRIP;
// reduce x to the position in the specific column
x %= 10;
// columns B & C are wired the same
if(base > 0) {
if(y & 0x01) {
// odd rows, reverse the ordering
uint8_t rx = (COL_WIDTH - 1) - x;
base += ((yCOL_WIDTH) + rx);
} else {
base += ((yCOL_WIDTH) + x);
}
} else {
// column A is upside down, making this trickier
uint8_t ry = (NUM_ROWS-1) - y;
if(ry & 0x01) {
base += ((ryCOL_WIDTH)+x;
} else {
uint8_t rx = (COL_WIDTH-1) -x ;
base += ((ryCOL_WIDTH)+rx;
}
}
Thank you sooooo much. It’s amazing that I have been working on this for a while and it takes you a couple of minutes to reply with a solution. I will let you know how it goes.
Thanks again Daniel
Thank you again for posting the code for the xmas lights, lol I’m still trying to figure out how to set every other 3 pixels green, but I forgot to also ask if there is a way to select multiple Pixels, for example, pix1,pix4,pix6,pix9 and then be able to utilize them later as a variable?
So as promised, here is my long hand code, as I always seem to bypass simplistic coding… http://pastebin.com/3WSwq5Vp
I know, I am terrible at coding, but most of the time it works lol. Now, I just need to get some extra things done like fading and such.