Hey,
I've started working on a LED project, basically, i need to control 500 LEDs over serial communication. I'm working with only 30LED strip (so i don't have to move around my desk 500LEDs (I tried all 500 LEDs and the problem is still there)), but i'm simulating it by code by just setting the length of the strip to 500 instead of 30.
I've found out that the limit is around 100 with the flickering.
If i call the .show function less (10x times a second instead of every serial input), it extends it to around 150LEDs and then it starts flickering again.
Anybody knows what could i be doing wrong ?
Thanks in advence!
My code:
#include <Adafruit_NeoPixel.h>
#ifdef __AVR__
#include <avr/power.h>
#endif
Adafruit_NeoPixel pixels0(150, 7, NEO_GRB + NEO_KHZ800);
int RedGlobal = 0;
int GreenGlobal = 0;
int BlueGlobal = 0;
int BrightnessGlobal = 10;
void setup() {
Serial.begin(9600);
delay(10);
pixels0.begin();
setcolor(255,255,255,1);
}
void setcolor(int red, int green, int blue, int brightness) {
pixels0.setBrightness(brightness);
pixels0.fill(pixels0.Color(red,green,blue));
pixels0.show();
}
void loop() {
if (Serial.available()){
char led_specifier = Serial.read();
int led_brightness = Serial.parseInt();
write_leds(led_specifier, led_brightness);
}
}
void write_leds(char led, int value){
if (led == 'r'){
RedGlobal = value;
setcolor(RedGlobal, GreenGlobal,BlueGlobal,BrightnessGlobal);
return;
}
if (led == 'g'){
GreenGlobal = value;
setcolor(RedGlobal, GreenGlobal,BlueGlobal,BrightnessGlobal);
return;
}
if (led == 'b'){
BlueGlobal = value;
setcolor(RedGlobal, GreenGlobal,BlueGlobal,BrightnessGlobal);
return;
}
if (led == 'j'){
BrightnessGlobal = value;
setcolor(RedGlobal, GreenGlobal,BlueGlobal,BrightnessGlobal);
return;
}
return;
}
(This is just a demonstration code for the problem, my real code is much more complex,but the problem is same)
https://streamable.com/2hoehm - How it works with 500 LEDs set in the code
https://streamable.com/wmexyj - How it works with 30 LEDs set in the code (the right way)