I have a project that uses Adafruit_NeoPixel with a light strip. I can set the light color easy enough using light2.setPixelColor(i, light);
Is there any way to return the color, once it is set using Adafruit_NeoPixel? I want to scroll a light down a strip. I can do it currently but there is a lot of overhead to the code and thought if I could get the color from the previous light set it to the next, it would eliminate a lot of unnecessary code. I am cant find any syntax for getting the pixel color. I thought it might be something like this but it doesn't work.
light2.setPixelColor(i, getPixelColor(i-1));
I thought it might be something like this but it doesn't work.
It is something that the writers of the library did not implement. However as you have the source code you could implement it yourself.
Great idea! I made the change and it appears to work great...
Now I have a new issue... It seems I can't run more than 1 light strand (5m - 300 lights), it freezes at If I try to run more lights, it freezes. I would like to run up to 6 light strands at 300 lights each.
Does anyone have any idea why the code would freeze, if I declare 2 light strands, my code freezes when processing the 23rd light.
Adafruit_NeoPixel lane1 = Adafruit_NeoPixel(300, 2, NEO_GRB + NEO_KHZ800);
Adafruit_NeoPixel lane2 = Adafruit_NeoPixel(300, 3, NEO_GRB + NEO_KHZ800);
Here is an example of the code loop. The code freezes at the 23rd light, every time I try to access the second light strand I declared, even if I do set the lights on the first strand. Is this an out of memory error? Is there a workaround?
void loop() {
// put your main code here, to run repeatedly:
for (int i = 2; i <= lightcount; i++) {
//lane1.setPixelColor(i, lane1.getPixelColor(i - 1));
//lane1.setPixelColor(i - 1, 0);
lane2.setPixelColor(i, lane2.getPixelColor(i - 1));
lane2.setPixelColor(i - 1, 0);
lane1.show();
lane2.show();
delay(lightdelay);
}
}
How many bytes does it take to define each LED's colour. Lets say it is 3 but it might be 4, it is hard to tell without seeing ALL your code.
For 300 lights, each one taking up 3 bytes that is 900 bytes. Double that for two strands and you have 1800 bytes. You don't say what sort of arduino you have, most of them only have 2K of SRAM so at 1800 bytes for your LEDs you are running out of memory.