Partial LED Strip Lighting (SK6812)

Using SK6812 LED Lights for a project and the entire strip will not light up under my custom code. The LEDs will only acknowledge the code if the code lists half or less than the total LEDs present. If I use another sketch that simply fills in the whole strip with one color, it works properly, so in theory this should rule out potential hardware issues. Lastly, a 470 Ohm resistor is placed between the data pin and Arduino. The custom code itself is rather extensive, and makes use of an IR Remote to control effects. I've been using a smaller strip composed of 30 LEDs to test the code and so far its worked perfectly. Is there any common issues that could lead to this problem? Thanks. Code listed below.

#include <IRremote.h>
#include <Adafruit_NeoPixel.h>

#define POWER 0xE0E040BF
#define VOL_UP 0xE0E0E01F
#define VOL_DOW 0xE0E0D02F
#define CH_UP 0xE0E048B7
#define CH_DOW 0xE0E008F7
#define MUTE 0xE0E0F00F
#define CH_RETURN 0xE0E0C837//INACTIVE
#define BUTTON_1 0xE0E020DF
#define BUTTON_2 0xE0E0A05F
#define BUTTON_3 0xE0E0609F
#define BUTTON_4 0xE0E010EF
#define BUTTON_5 0xE0E0906F
#define BUTTON_6 0xE0E050AF
#define BUTTON_7 0xE0E030CF
#define BUTTON_8 0xE0E0B04F
#define BUTTON_9 0xE0E0708F
#define BUTTON_DOT 0xE0E0C43B//INACTIVE
#define BUTTON_0 0xE0E08877
#define BUTTON_INPUT 0xE0E0807F//INACTIVE
#define LED_PIN 13
#define NUM_LEDS 430

int RECV_PIN = 2;//IR PIN
int DELAY = 2;
int CHECK;
int brightness_steps = 15;//Needs to be greater than 1; Higher Value Slower Brightness Changes
int Brightness;
int Brightness_Reduced = 38.25;//15% Max Power for Sleep
int Power_Button_Value = 0;
int Power_Button_change;
int color_change;
int num;
int number = 1;
uint16_t i, j;
int r, g, b, w, z;
int DELAY2 = 2000;
int x = 0;

Adafruit_NeoPixel strip = Adafruit_NeoPixel(NUM_LEDS, LED_PIN, NEO_WRGB + NEO_KHZ800);
IRrecv irrecv(RECV_PIN);
decode_results results;

void setup() {
Serial.begin(9600);
irrecv.enableIRIn(); // Start the receiver
strip.begin();
strip.show();
Brightness = 255;
color_change = 0;
strip.setBrightness(Brightness);
Bootup();//Custom Effect When Power is Supplied to Strip
strip.fill(strip.Color(0, 0, 0, 0));//Off
strip.show();
}

void loop() {
if (irrecv.decode(&results)) {
 delay(DELAY);
 Power();
 delay(DELAY);
 Mute();
 delay(DELAY);
 Button_1();
 delay(DELAY);
 Button_2();
 delay(DELAY);
 Button_3();
 delay(DELAY);
 Button_4();
 delay(DELAY);
 Button_5();
 delay(DELAY);
 Button_6();
 delay(DELAY);
 Button_7();
 delay(DELAY);
 Button_8();
 delay(DELAY);
 Button_9();
 delay(DELAY);
 Button_0();
 delay(DELAY);
 Vol_Up();
 delay(DELAY);
 Vol_Down();
 delay(DELAY);
 Ch_Up();
 delay(DELAY);
 Ch_Down();
 delay(DELAY);
 Flash_Red();
 delay(DELAY);
 if (results.value == MUTE) {
   strip.setBrightness(Brightness_Reduced);
 }
 else {
   strip.setBrightness(Brightness);
 }
 strip.show();
 delay(DELAY);
 irrecv.resume(); // Receive the next value
 delay(50);
}
}

void Power() {
if (results.value == POWER) {
 strip.fill(strip.Color(0, 0, 0, 0));
 Serial.println("POWER Pressed");
}
}

void Vol_Up() {
if (results.value == VOL_UP) {
 if ( Brightness + 255 / brightness_steps < 255) {
   Brightness = Brightness + 255 / brightness_steps;
   Serial.println(Brightness);
 }
 else {
   Brightness = 255;
   Serial.println(Brightness);
 }
}
}

void Vol_Down() {
if (results.value == VOL_DOW) {
 if ( Brightness - 255 / brightness_steps > 0) {
   Brightness = Brightness - 255 / brightness_steps;
   Serial.println(Brightness);
 }
 else {
   Brightness = 5;
   Serial.println(Brightness);
 }
}
}

void Ch_Up() {
if (results.value == CH_UP) {
 if ((color_change + 1) > 12) {
   color_change = 0;
   Serial.println(color_change);
 }
 else {
   color_change = color_change + 1;
   Serial.println(color_change);
 }
 delay(50);
 Color_Change();
}
}

void Ch_Down() {
if (results.value == CH_DOW) {
 if ((color_change - 1) < 0) {
   color_change = 12;
   Serial.println(color_change);
 }
 else {
   color_change = color_change - 1;
   Serial.println(color_change);
 }
 delay(50);
 Color_Change();
}
}

void Mute() {
if (results.value == MUTE) {
 strip.fill(strip.Color(0, 0, 255, 0));//white
 Serial.println("Mute Button Pressed");
}
}

void Flash_Red() {//Inactive - Red Flash
if (results.value == CH_RETURN || results.value == BUTTON_DOT || results.value == BUTTON_INPUT || results.value == BUTTON_9) {
 strip.setBrightness(255);
 for (j = 255; j > 0; j--) {
   for (i = 0; i < strip.numPixels(); i++) {
     strip.setPixelColor(i, j, 0, 0, 0);
   }
   strip.show();
   delay(0.1);
   if (j < 0.01) {
     break;
   }
 }
 for (j = 255; j > 0; j--) {
   for (i = 0; i < strip.numPixels(); i++) {
     strip.setPixelColor(i, j, 0, 0, 0);
   }
   strip.show();
   delay(2);
   if (j < 0.01) {
     break;
   }
 }
 strip.fill(strip.Color(0, 0, 0, 0));
 strip.show();
 Serial.println("Flash Red");
}
}

void Button_1() {
if (results.value == BUTTON_1) {
 Serial.println("Button 1 Pressed");
 while (results.value == BUTTON_1) {
   RunningLights(0, 0, 0xff, 0, 50); // white
   if (irrecv.decode(&results)) {
     Serial.println(results.value, HEX);
     if (results.value == POWER || results.value == VOL_UP  || results.value == VOL_DOW || results.value == MUTE || results.value == BUTTON_2 || results.value == BUTTON_3 || results.value == BUTTON_4 || results.value == BUTTON_5 || results.value == BUTTON_6 || results.value == BUTTON_7 || results.value == BUTTON_8 || results.value == BUTTON_9 || results.value == BUTTON_0 ) {
       strip.fill(strip.Color(0, 0, 0, 0));
       strip.show();
       break;
     }
     irrecv.resume();
   }
 }
}
}

void Button_2() {
if (results.value == BUTTON_2) {
 while (results.value == BUTTON_2) {
   Serial.println("Button 2 Pressed");
   Twinkle(0, 0, 0xff, 0, 10, 10, false);
   if (irrecv.decode(&results)) {
     Serial.println(results.value, HEX);
     if (results.value == POWER || results.value == VOL_UP  || results.value == VOL_DOW || results.value == MUTE || results.value == BUTTON_1 || results.value == BUTTON_3 || results.value == BUTTON_4 || results.value == BUTTON_5 || results.value == BUTTON_6 || results.value == BUTTON_7 || results.value == BUTTON_8 || results.value == BUTTON_9 || results.value == BUTTON_0 ) {
       strip.fill(strip.Color(0, 0, 0, 0));
       strip.show();
       break;
     }
     irrecv.resume();
   }
 }
}
}

void Button_3() {
if (results.value == BUTTON_3) {
 Serial.println("Button 3 Pressed");
 while (results.value == BUTTON_3) {
   RGBLoop();
   if (irrecv.decode(&results)) {
     Serial.println(results.value, HEX);
     if (results.value == POWER || results.value == VOL_UP  || results.value == VOL_DOW || results.value == MUTE || results.value == BUTTON_1 || results.value == BUTTON_2 || results.value == BUTTON_4 || results.value == BUTTON_5 || results.value == BUTTON_6 || results.value == BUTTON_7 || results.value == BUTTON_8 || results.value == BUTTON_9 || results.value == BUTTON_0 ) {
       strip.fill(strip.Color(0, 0, 0, 0));
       strip.show();
       break;
     }
     irrecv.resume();
   }
 }
}
}

void Button_4() {
if (results.value == BUTTON_4) {
 Serial.println("Button 4 Pressed");
 while (results.value == BUTTON_4) {
   CylonBounce(0xff, 0, 0, 0, 4, 25, 50);
   if (irrecv.decode(&results)) {
     if (results.value == POWER || results.value == VOL_UP  || results.value == VOL_DOW || results.value == MUTE || results.value == BUTTON_1 || results.value == BUTTON_2 || results.value == BUTTON_3 || results.value == BUTTON_5 || results.value == BUTTON_6 || results.value == BUTTON_7 || results.value == BUTTON_8 || results.value == BUTTON_9 || results.value == BUTTON_0 ) {
       strip.fill(strip.Color(0, 0, 0, 0));
       strip.show();
       break;
     }
     irrecv.resume();
   }
 }
}
}

OK, first things first.

You need to go and read the forum instructions so that you can go back and modify your original post (not re-post it) - using the "More -> Modify" option below the right hand corner of your post - to mark up your code as such using the "</>" icon in the posting window. Just highlight each section of code (or output if you need to post that) from the IDE and click the icon.

In fact, the IDE itself has a "copy for forum" link to put these markings on a highlighted block for you so you then just paste it here in a posting window. But even before doing that, don't forget to use the "Auto-Format" (Ctrl-T) option first to make it easy to read. If you do not post it as "code" it can easily be quite garbled and is always more difficult to read due to the font.

It is inappropriate to attach it as a ".ino" file unless it is clearly too long to include in the post proper. People can usually see the mistakes directly and do not want to have to actually load it in their own IDE. And even that would also assume they are using a PC and have the IDE running on that PC.

Also tidy up your blank space. Do use blank lines, but only single blanks between complete functional blocks.

Trying to control a bedroom LED strip with an IR Remote. When I upload the code, the LED Strip doesnt acknowledged it and the last effect remains frozen. Ive narrowed down the problem to the IR library itself. I also tried several libraries, but nothing has worked so far. It keeps freezing the strip. It should also be noted, the the code with the IR library works on a smaller strip (~30 LEDS) but not the larger strip (422 LEDS). Any help will be greatly appreciated.

#include <Adafruit_NeoPixel.h>
#define LED_PIN 11
#define LED_COUNT 422
Adafruit_NeoPixel strip(LED_COUNT, LED_PIN, NEO_WRGB + NEO_KHZ800);

[b]
//#include <IRremote.h>//LIBRARY 1
//#include "IRLremote.h" //LIBRARY 2
//#include <IRsmallDecoder.h>//LIBRARY 3
[/b]

void setup() {
  Serial.begin(9600);
  strip.begin();
  strip.show();
  strip.setBrightness(255);
}

void loop() {
  RunningLights(0, 0, 0xff, 0, 1); // GOOD
}

void RunningLights(byte red, byte green, byte blue, byte white, int WaveDelay) {
  //BUTTON 1
  int Position = 0;
  for (int j = 0; j < LED_COUNT * 2; j++) {
    Position++; // = 0; //Position + Rate;
    for (int i = 0; i < LED_COUNT; i++) {
      setPixel(i, ((sin(i + Position) * 127 + 128) / 255)*red, ((sin(i + Position) * 127 + 128) / 255)*green, ((sin(i + Position) * 127 + 128) / 255)*blue, ((sin(i + Position) * 127 + 128) / 255)*white);
    }
    strip.show();
    delay(WaveDelay);
  }
}

void setPixel(int Pixel, byte red, byte green, byte blue, byte white) {
  strip.setPixelColor(Pixel, strip.Color(red, green, blue, white));
}

The sketch you posted has no code to receive or action any IR commands. So it won't "acknowledged" anything. Did you post that sketch by mistake? It doesn't help us diagnose why your other sketch, the one that receives IR commands, works with 30 LEDs but not 400.

But it may be that because updating a longer strip takes longer, parts of the IR signal are lost. If your sketch updates the strip too frequently, there may be no opportunity for it to receive the IR signal in full.

Working with SK6812 LEDs and want to control them with an IR remote. For some reason the code freezes up the LED strip and is totally unresponsive when any other library is included, such as <Wire.h> or <IRremote.h>. I originally tried to use the IR remote library directly with the LED effects code and it never worked no matter how simple the code was(Trial #1). I then tried to use I2C to transfer the values thinking the IR Remote library was an isolated issue. It was not. The Wire library had the same issue. To my knowledge any other library included with the Adafruit Library causes the strip to become totally unresponsive. I believe my goal of controlling the LEDs around my room with an IR remote is nearly impossible at this point. Please help. The code listed below uses the IR library directly with the effects (Trial #1). Lastly it should be noted that the code below works on a smaller strip (~30 LEDs) but not the larger strand (~430 LEDs).

#include <Adafruit_NeoPixel.h>
#define LED_PIN 11
#define NUM_LEDS 30
Adafruit_NeoPixel strip(NUM_LEDS, LED_PIN, NEO_WRGB + NEO_KHZ800);

#include <IRremote.h>

#define BUTTON_1 0xE0E020DF
#define BUTTON_2 0xE0E0A05F
#define BUTTON_3 0xE0E0609F
#define BUTTON_4 0xE0E010EF

int RECV_PIN = 2;//IR PIN
int DELAY = 2;

IRrecv irrecv(RECV_PIN);
decode_results results;

void setup() {
  Serial.begin(9600);
  irrecv.enableIRIn(); // Start the receiver
  strip.begin();
  strip.setBrightness(255);
}

void loop() {
  if (irrecv.decode(&results)) {
    Button_1();
    delay(DELAY);
    Button_2();
    delay(DELAY);
    Button_3();
    delay(DELAY);
    Button_4();
    delay(DELAY);
    irrecv.resume();
    delay(50);
  }
}

void Button_1() {
  if (results.value == BUTTON_1) {
    strip.fill(strip.Color(0, 0, 0, 0));
    strip.show();
  }
}

void Button_2() {
  if (results.value == BUTTON_2) {
    strip.fill(strip.Color(255, 0, 0, 0));
    strip.show();
  }
}

void Button_3() {
  if (results.value == BUTTON_3) {
    strip.fill(strip.Color(0, 0, 0, 255));
    strip.show();
  }
}

void Button_4() {
  if (results.value == BUTTON_4) {
    strip.fill(strip.Color(0, 0, 255, 0));
    strip.show();
  }
}

To my knowledge any other library included with the Adafruit Library causes the strip to become totally unresponsive.

This is incorrect. I regularly use the Wire library with Adafruit Library.

Use the manage libraries box to make sure you libraries are up to date.

Then post some short code that you claim does not work.

Lastly it should be noted that the code below works on a smaller strip (~30 LEDs) but not the larger strand (~430 LEDs).

No surprise. Each LED takes up three bytes of memory so 430 LEDs will take up 1290 bytes and there is only 2048 bytes in an Arduino. This memory usage does not show up in the final compiler message because it is allocated by the code itself not the compiler. So you are more likely to be running out of memory rather than have a library incompatibility.

Mind you there are well known libraries that you can not use with Neopixels no matter what library you use. Like the servo library, and serial input, due to having turn off interrupts during the data transfer.

I've merged/deleted your other cross-posts cjr7315.

Cross-posting is against the rules of the forum. The reason is that duplicate posts can waste the time of the people trying to help. Someone might spend 15 minutes (or more) writing a detailed answer on this topic, without knowing that someone else already did the same in the other topic.

Repeated cross-posting will result in a suspension from the forum.

In the future, please take some time to pick the forum board that best suits the topic of your question and then only post once to that forum board. This is basic forum etiquette, as explained in the sticky "How to use this forum - please read." post you will find at the top of every forum board. It contains a lot of other useful information. Please read it.

Thanks in advance for your cooperation.

And while you are at it, OP, fix the first post in this sorry list as I described, otherwise people may choose not to read down through it! :astonished:


Thank you . That's much better. :grinning:

Original Code is fixed and up to standards to my understanding. Updated all libraries and uploaded the code to a Mega instead of a Uno and everything is running as it should. It seems it was indeed a memory issue. All the problems are ironed out except one. When an effect is started is cant be stopped. I tried to insert a break if any other IR code is received but it doesn't work. The quicker and more responsive the effect changes the better. Heres an effect and my attempt to break it instead of running a full loop. Any ideas? Thanks.

void RGBLoop() {
  //BUTTTON 3
  for (int j = 0; j < 4; j++ ) {
    // Fade IN
    for (int k = 0; k < 255; k++) {
      switch (j) {
        case 0: setAll(k, 0, 0, 0); break;
        case 1: setAll(0, k, 0, 0); break;
        case 2: setAll(0, 0, k, 0); break;
        case 3: setAll(0, 0, 0, k); break;
      }
//ATTEMPT TO BREAK - START
      if (irrecv.decode(&results)) {
        if (results.value == POWER || results.value == VOL_UP  || results.value == VOL_DOW || results.value == MUTE || results.value == BUTTON_1 || results.value == BUTTON_2 || results.value == BUTTON_4 || results.value == BUTTON_5 || results.value == BUTTON_6 || results.value == BUTTON_7 || results.value == BUTTON_8 || results.value == BUTTON_9 || results.value == BUTTON_0 ) {
          Break = 1;
          break;
        }
        irrecv.resume(); // Receive the next value
      }
//ATTEMPT TO BREAK - END
      showStrip();
      delay(1);
    }
    // Fade OUT
    for (int k = 255; k >= 0; k--) {
      switch (j) {
        case 0: setAll(k, 0, 0, 0); break;
        case 1: setAll(0, k, 0, 0); break;
        case 2: setAll(0, 0, k, 0); break;
        case 3: setAll(0, 0, 0, k); break;
      }
//ATTEMPT TO BREAK - START
      if (irrecv.decode(&results)) {
        if (results.value == POWER || results.value == VOL_UP  || results.value == VOL_DOW || results.value == MUTE || results.value == BUTTON_1 || results.value == BUTTON_2 || results.value == BUTTON_4 || results.value == BUTTON_5 || results.value == BUTTON_6 || results.value == BUTTON_7 || results.value == BUTTON_8 || results.value == BUTTON_9 || results.value == BUTTON_0 ) {
          Break = 1;
          break;
        }
        irrecv.resume(); // Receive the next value
      }
//ATTEMPT TO BREAK - END
      showStrip();
      delay(1);
    }
    if (Break == 1) {
      break;
    }
  }
}

When an effect is started is cant be stopped.

We get this almost every day.
The way to get round is to implement the animation routines as a state machine. I have posted many examples of this.
You have to not use delay at all and unroll any for loops that used to contain a delay.
This ensures that your animation keeps returning very frequently. This gives an opportunity to stop it or switch to something new.

You can not use break to do this, it doesn’t work the way you think. You could have an interrupt service routine return to a different place but you can’t actually code this in C you would have to use machine code.