Hi to all members,

Hi to all members, nice to meet you!

i’m working on a project with 600/1200 led and teensy.

I have a problem with flickering of brightness when it is lower then 255, specially when they are stopped in one position and the data keeps coming.

I tried to use FastLED.setDither(0) without improvements.

Any suggest?

Another question: the data is many, is there any control I can put in the sketch to avoid bugs?

Thank you!

My sketch:

#include “FastLED.h”

int value = 10;
int i = 0;
int i2 = 0;
int i3 = 0;
int fade = 0;

#define NUM_LEDS_PER_STRIP 300
#define NUM_LEDS_PER_STRIP2 60
#define NUM_LEDS_PER_STRIP3 300

CRGB leds[NUM_LEDS_PER_STRIP];
CRGB leds2[NUM_LEDS_PER_STRIP2];
CRGB leds3[NUM_LEDS_PER_STRIP3];

void setup() {

Serial.begin(921600);
Serial.println(“resetting”);

FastLED.addLeds<WS2812B, 3>(leds, NUM_LEDS_PER_STRIP);
FastLED.addLeds<WS2812B, 10>(leds2, NUM_LEDS_PER_STRIP2);
FastLED.addLeds<WS2812B, 15>(leds3, NUM_LEDS_PER_STRIP3);

FastLED.setBrightness( 255 );
FastLED.setDither(0);

}

void loop() {

if (Serial.available()){

if ((i3 >= 0) && (i3 <= 299)){
  value = Serial.read(); 
  i = i3;
  leds[i] = CRGB(value, value, value); 
  i3++;
}


if ((i3 >= 300) && (i3 <= 359)){
  value = Serial.read();
  i = i3-300;
  leds2[i] = CRGB(value, value, value);
  i3++;
}


if ((i3 >= 360) && (i3 <= 659)){
  value = Serial.read();
  i = i3-360;
  leds3[i] = CRGB(value, value, value);
  i3++;
}


if ( i3 == 660){
   FastLED.show();
   i3 = 0;
}

}

}

What’s sending the data? Do you have any control over how the data is sent? And just to confirm, how is the data formatted?

When sharing code please put it on http://gist.github.com and share the link. That way code will always be displayed correctly on all devices and line numbers can be referenced for discussion.

@lorenzo_ballerini - What are you trying to accomplish with your sketch? Are you trying to get all of your LED strips being on at the same time with the same color and brightness based on a serial input?

@marmil Hi Marc, thank you for the reply, i understand. I use max msp via serial port to send data packets. Every packet have 900 bites. i send the same data to the R-G-B to have white and control brightness. 0-0-0 to 255-255-255

@Ken_White thank you for reply. I’m trying to control the brightness via max msp of every single led (separately) but i have this problem. The data arrive well but when i stop the led oh a specific brightness i have rumbles. I use only white.

Have you tested with sending data for fewer pixels. Maybe just 20 for example? Any difference?

Have you monitored the actual values of a single pixel to verify it is what you think it should be, and also not jumping around went you think it should be a constant value?

@marmil yes, i tried with 300 leds in one output of teensy and all ok. all data arrives well

@lorenzo_ballerini as you have a ‘long’ loop do you try tot reduce the speed of the serial ? In order to accommodate with the duration of the tests in your loop. ? Could you also publish a video of the results ? I am not sure I understand the issue that you have.

@Yves_BAZIN i tried 36000 to higher baud/s, the problem arrives in the first led strip (on the first 300 leds). Maybe there is some problem in the first loop. I tried to view the data on serial monitor and there is a problem around the 60/70th led…it jump at 128th but if i turn on the 110th led (for example) it works!..i don’t know if the serial monitor wrong or the loop. very strange. this is the video of my problem

@lorenzo_ballerini how do you send the data ? Do you have a program or ‘manually’ ? Could you reduce more the speed like 9600 ?

That video makes it look like pixels are getting set back to 0,0,0 for a brief moment.
Can you try Yves’ suggestion of a slower baud, 9600? Also did you try a very small number of pixels, like 20? What if you just do a single pixel and monitor the values for that?

The data packets you’re sending are 900 bytes? Is that the RGB all in one packet? How are those put together on the MAX MSP side?

I was just looking at how the serial read for receiving data from Glediator was done and it’s like this:
Serial.readBytes((char*)leds, NUM_LEDS * 3);

I’ve also seen it done this way:
Serial.readBytes( (char*)(&leds[i]), 3); // read three bytes at a time

You don’t have any markers for the beginning of the frame - you also said you are sending 900 bytes but you are only using 660 - which means your data is likely getting shifted in weird ways - also while the led data is being written out (which will take about 20ms) you might serial data depending on how large the internal serial buffers are. This is why packages light adalight have a “magic sequence” of bytes that get sent to mark the beginning of a frame - and it will keep reading until it gets that sequence then start a frame.

Ah thank you @Daniel_Garcia . That was going to be my next question-- if there was a way for MAX MSP to output something to designate the start of a frame.

Yes, thank you @marmil and Daniel. Was the second question i asked. maybe i can sacrifice the number 255 and use it to start the frame?
Anyway the problem of the fluttering brightness was the cable of the ground, the last thing I would have thought of. Now everything goes well. Thank you to all. i’ll study something to start the frame in the right way.