neopixel lights not correct length

hey guys. I am a bit perplexed by my code as to why it is not working... any suggestions would be great. Below I have some code that listens for an incoming MQTT topic and then based on if it was the one that published the topic or it was another device it does stuff.
Currently my problem lies in when some other device publishes a topic. It finds it and parses the incoming char array to check to see if its from someone else. It then puts some neopixels in a while loop to light them all up white.
my problem is that not all the neopixels light up and I dont know why. currently I have 9 neopixels but only 7 light up. If I define it having 11 pixels all 9 light up but the last one is green. weird.
I have put a debug in the while loop for serial output to see if it actually is counting all the way to 9. It IS actually reaching all the way to 9 so I dont know why the setpixelcolor 1-9 is not doing ALL 9.

Any suggestions?

void callback(char* topic, byte* payload, unsigned int length) {
 
  Serial.print("Message arrived in topic: ");
  Serial.println(topic);
 
  Serial.print("Message:");
  for (int i = 0; i < length; i++) {
    
    Serial.print((char)payload[i]);
  }
  Serial.println(" ");
  Serial.print("Payload Array 0 = "); 
    Serial.println((char)payload[0]);
    Serial.println(CLIENT_ID_INT);
    if (payload[0] == CLIENT_ID_INT )
    {Serial.println("I published the hash");
     Serial.println(payload[0]);
     int count = 0;
     while (count <= 5)
     {
     
     count++;
     Serial.println(count);
     }
    }
    else 
    {
    int i = 1; 
    while (i <= PIXEL_COUNT) 
    {
      pixels.setPixelColor( i, 255,255,255);
      Serial.println (i);
      i++;   
    }
    pixels.show();
      Serial.println("Someone else published the hash");
    }

  


  Serial.println();
  Serial.println("-----------------------");
 
}

if you need to view the full code - Family_Lights/Family_lights.ino at master · davidginn524/Family_Lights · GitHub

const int BUTTON_PIN = 0;
  pinMode(BUTTON_PIN, INPUT);
Serial.begin(115200);

Those three lines of code do not belong in the same Arduino sketch. If you are not using an Arduino, it would be good of you to say what you ARE using.

    int i = 1; 
    while (i <= PIXEL_COUNT) 
    {
      pixels.setPixelColor( i, 255,255,255);
      Serial.println (i);
      i++;   
    }
pixels.show();

On my pixel strips, the first pixel is numbered 0.

What do you have against for loops? That would be the preferred statement to use to iterate a fixed number of times.

PaulS:

const int BUTTON_PIN = 0;

pinMode(BUTTON_PIN, INPUT);
Serial.begin(115200);



Those three lines of code do not belong in the same Arduino sketch. If you are not using an Arduino, it would be good of you to say what you ARE using.

That is fair. My bad :stuck_out_tongue: I am using a ESP8266. Its actually A Wemos pro D1 Mini. You are right I should have said that my bad. Ill do that for future posts

    int i = 1; 

while (i <= PIXEL_COUNT)
   {
     pixels.setPixelColor( i, 255,255,255);
     Serial.println (i);
     i++;  
   }
pixels.show();



On my pixel strips, the first pixel is numbered 0.

What do you have against for loops? That would be the preferred statement to use to iterate a fixed number of times.

Nothing against for loops. This is just what to came to mind first, and tbf i don't know any better which one is better in what senario. Yeah you are right about i = 0 . I originally had 0 but changed it in hopes of maybe making a difference. I was thinking worse case sernario it sets all of them except the first LED (0) on.
I have now implemented it and pushed a change. It still does the same thing. I now dont think its the loop doing it because even if I manually set all pixels. the last 2 still dont light up. I do know that they work if I set the pixel count to 11 they turn on.

pixels.setPixelColor(0, 255,255,255);
pixels.setPixelColor(1, 255,255,255);
etc etc

However since I have changed this when I initialize them the first pixel now sets itself to green when I clearly tell all pixels in the setup to start with nothing

    for (int i=0; i<PIXEL_COUNT; ++i) 
    {
      pixels.setPixelColor(i, 255,255,255);
      Serial.println (i);
    }

Also yes before anybody comments. i know i shouldn't be using strings..... sorry waste of memory. i will eventually be changing these this was just a quick prototype to get stuff working. [/quote]

you know what.............. I am an idiot.............. I am currently programming this for W2812b lights... however... i am using sk6812 pixels.....
Sorry about the waste of time guys. my code was right. im just dumb and grab the wrong LEDS