Reply to thread

Okay, the capacitor did not solve the problem, it's still the same. I even encountered flickering of the leds at the beginning, but not anymore.


I am now using my Arduino Uno to debug. I have 1 WS2812B led on pin 13 and one "debug" led on pin 10. I am not using an external power supply in this setup, so I can rule out a lot of factors. The result is that the problem also occur with this setup. The leds get stuck when playing with the static color. What I can see is that the Arduino still gets serial code (RX led flashes) when playing with it, but the RGB led does not change. I am also testing this code:

[code]

#include <FastLED.h>


// Set the number of leds in the strip.

#define NUM_LEDS  64

#define DATA_PIN  13

#define BRIGHTNESS  255

#define LED_TYPE  WS2812B

#define COLOR_ORDER GRB

CRGB leds[NUM_LEDS];


void setup(){

  Serial.begin(115200);

  pinMode(10, OUTPUT);

  pinMode(11, OUTPUT);

  //sanity check delay - allows reprogramming if accidently blowing power w/leds

  delay(2000);

  FastLED.addLeds<LED_TYPE, DATA_PIN, COLOR_ORDER>(leds, NUM_LEDS);

  FastLED.setBrightness(BRIGHTNESS);


  setupLEDs();

  loopLeds();

  clearLeds();

  //blinkLeds();

}


int readByte(){

  while (Serial.available() == 0){ /* wait for data */ }

  return Serial.read();

}


void loopLeds(){

for(int j = 0; j < 3; j++) {

  for(int i = 0 ; i < NUM_LEDS; i++ ) {

  memset(leds, 0, NUM_LEDS * 3);

  switch(j) {

  case 0: leds[i].r = 255; break;

  case 1: leds[i].g = 255; break;

  case 2: leds[i].b = 255; break;

  }

  FastLED.show();

  delay(5);

  }

  }

}



void clearLeds(){

  for(int dot = 0; dot < NUM_LEDS; dot++){

  leds[dot] = CRGB::Black;

  };

  FastLED.show();

}


// shows colored LEDs for 500ms then blanks out ready to go

void setupLEDs()

{

  memset(leds,150, sizeof(leds));

  FastLED.show();

  FastLED.delay(500);

  memset(leds,0, sizeof(leds));

  FastLED.show();

}


void loop() {


  if(readByte() == 0xFF){

  if(readByte() == 0x00){

  if(readByte() == 0x00){

  int channels = readByte();

  for(int dot = 0; dot < channels; dot++){

  leds[dot].r = readByte();

  leds[dot].g = readByte();

  leds[dot].b = readByte();

  }

  FastLED.show();


  digitalWrite(10, HIGH);

  delay(300);

  digitalWrite(10, LOW);



  }

  }

  }

}[/code]


This works fine, the RGB led (WS2812B) gets data once in a while and after that it has to wait 300ms to be able to receive a new signal. The failure is less likely to occur, but still happens after a while. The Arduino still gets serial data, but as it seems, never the "right" data. The RGB led and the normal LED never change/flash anymore.



EDIT:

What?! I just placed the led code in front of the FastLED code and the problem does not happen anymore!

Like this:

[code]

void loop() {

   if(readByte() == 0xFF){

  if(readByte() == 0x00){

  if(readByte() == 0x00){

 

  digitalWrite(10, HIGH);

  delay(150);

  digitalWrite(10, LOW);


  int channels = readByte();

  for(int dot = 0; dot < channels; dot++){

  leds[dot].r = readByte();

  leds[dot].g = readByte();

  leds[dot].b = readByte();

  }

  FastLED.show();

    }

  }

  }

}

[/code]


Maybe it's because of the delay?


Edit:

I tested it, the lowest I could get is 6ms delay. I can put it anywhere before the FastLED.show(), but the output is not okay. The leds don't lock up, but it's not the right solution because the output to the leds is not okay. I get different colors or flashes when playing with the static color sliders. Color changer mode is okay.


I have no idea what's going on.


Top Bottom