NeoPixel Jewel Showing Random Colors

So I've been trying to get this NeoPixel Jewel to work for a bit and it works on TinkerCAD however when I actually upload it, it shows just random colors. I'm trying to just have them all show up as blue. I've also tried individually coding the LED's too but that hasn't worked either.

#include <Adafruit_NeoPixel.h>


int LEDPIN = 6;


int NUMPIXELS = 7;


Adafruit_NeoPixel pixels = Adafruit_NeoPixel(NUMPIXELS, LEDPIN, NEO_GRB + NEO_KHZ800);

void setup() {
  pixels.begin();
  pixels.setBrightness(40); 
}

void loop() {

 

 
  pixels.setPixelColor(0, pixels.Color(0,0,250)); 
  pixels.setPixelColor(1, pixels.Color(0,0,250)); 
  pixels.setPixelColor(2, pixels.Color(0,0,250)); 
  pixels.setPixelColor(3, pixels.Color(0,0,250)); 
  pixels.setPixelColor(4, pixels.Color(0,0,250)); 
  pixels.setPixelColor(5, pixels.Color(0,0,250)); 
  pixels.setPixelColor(6, pixels.Color(0,0,250)); 
  pixels.setPixelColor(7, pixels.Color(0,0,250));

  pixels.show(); 
}
#include <Adafruit_NeoPixel.h>                                         
int dataPin = 6;                           

#define numberOfPixels  7                 

#define maximumBrightness 250              
                                           

Adafruit_NeoPixel ledStrip = Adafruit_NeoPixel(numberOfPixels, dataPin); 
                                                                         
                                                                         

void setup() 
  {
      ledStrip.begin();  
      ledStrip.setBrightness(40);                         
  }


void loop() 
  {
   customLight();                               
   
    
  }


void customLight()                                    
  {
    setLightsToColour(0,0,250);                       
                                                       
  }                                                  




void setLightsToColour(int red, int green, int blue)                      
  {
     for (uint8_t i = 0; i < numberOfPixels; i++)                          
     {
        ledStrip.setPixelColor(i, ledStrip.Color(red, green, blue));       
       
     }
     
     ledStrip.show();                                                      
  }

image
I get something like this(sorry for the blurry photo)

Which of your two sketches are you referencing? If I were to guess, the one with "max 250" is the one making random colors. Try using only one PIXEL, and remove all the other stuff until you get that working.

Both of them yield similar results. The first one I just tried to code each LED specifically

Are you plugging the jewel into a breadboard? I have found them to be intermittent in connections.

No, its plugged straight into Arduino Uno: Ground, 5V, and Pin 6

Use the data line form the (mcu) but power the jewel directly from a power supply. Be sure to share ground with the (mcu).

#include <Adafruit_NeoPixel.h>


int LEDPIN = 6;


int NUMPIXELS = 7;


Adafruit_NeoPixel pixels = Adafruit_NeoPixel(NUMPIXELS, LEDPIN, NEO_GRB + NEO_KHZ800);

void setup() {
  pixels.begin();
  pixels.setBrightness(100); 
}

void loop() {


  pixels.setPixelColor(6, pixels.Color(0,250,0));
  pixels.setPixelColor(4, pixels.Color(0,0,250));
  pixels.setPixelColor(3, pixels.Color(250,0,0));
 
 
  pixels.show(); 
}

So I've done this now and it's able to generate parts of it but when I start to add more LED's into the code it messes with the other LED's rather than turning on and changing another LED. Sometimes it does both depending on what LED number I reference and the RGB color.
image

...

What do you mean? Also, I played around with the code and I changed the number of "int NUMPIXELS = 9" to 9 now so I can have more options so to say when choosing an LED now this works but I really want to know why.

#include <Adafruit_NeoPixel.h>

int LEDPIN = 6;

int NUMPIXELS = 9;

Adafruit_NeoPixel pixels = Adafruit_NeoPixel(NUMPIXELS, LEDPIN, NEO_GRB + NEO_KHZ800);

void setup() {
  pixels.begin();
  pixels.setBrightness(100); 
}

void loop() {

  pixels.setPixelColor(6, pixels.Color(0,250,0));
  pixels.setPixelColor(4, pixels.Color(0,0,250));
  pixels.setPixelColor(3, pixels.Color(250,0,0));
  pixels.setPixelColor(0, pixels.Color(0,0,250));
  pixels.setPixelColor(2, pixels.Color(0,250,0));
  pixels.setPixelColor(1, pixels.Color(0,0,0));
  pixels.setPixelColor(7, pixels.Color(250,0,0));
  pixels.setPixelColor(8, pixels.Color(0,0,250));

  pixels.show(); 
}

image

7, 8 and 9 are not valid. The jewel only has seven.

This will shows as "not working" (off)

For some reason, it works. I entered the number 8 as a test and one of the LED's popped up blue

If you have seven pixels, the count is from 0 to 6. Maybe the library wraps seven to zero (or it creates a negative number in the library). You could put in almost any number of NUMPIXELS... but beyond "seven" they are not valid.

It looks like you have RGBW LEDs.
Try

Adafruit_NeoPixel pixels = Adafruit_NeoPixel(NUMPIXELS, LEDPIN, NEO_GRBW + NEO_KHZ800);

Yea, I understand that which is why I was confused when I inputted 8

That seems to have been the problem. Thank you so much for your help!

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.