WS2812B Problems Addressing Individual Neopixels

EL Wire/Tape/Panels, LEDs, pixels and strips, LCDs and TFTs, etc products from Adafruit

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
insultcomicdog
 
Posts: 25
Joined: Mon Apr 02, 2012 1:04 am

WS2812B Problems Addressing Individual Neopixels

Post by insultcomicdog »

Hi All,

I'm build a smart night light for my son using Neopixels. I have 8 WS2812B individual Neopixels daisy chained in my 3D printed housing being controlled by an Adafruit 5V Trinket with an external battery supply for lights.

See it in action here:
https://vimeo.com/89469312

Each letter has two lights, and the order of the Neopixels goes like this per letter of his name goes like this:

O - 1, 2
W - 3, 4
E - 5, 0
N - 6, 7

This code block lights a random Neopixel to a random colour. This works fine. All lights start off, then get light up randomly until they are all on.

Code: Select all

#include <Adafruit_NeoPixel.h>

   

#define PIN 0

#define MAXLED 8

#define MAXCOLOR 255

   

Adafruit_NeoPixel pixels = Adafruit_NeoPixel(8, PIN);

void setup() {

pixels.begin();

pixels.setBrightness(83); // 1/3 brightness

pixels.show();

//shadesOfBlue();

}

void shadesOfBlue() {
  pixels.setPixelColor(1, 104, 131, 139);
  pixels.setPixelColor(2, 104, 131, 139);
  
  pixels.setPixelColor(3, 154, 192, 205);
  pixels.setPixelColor(4, 154, 192, 205);

  pixels.setPixelColor(5, 178, 223, 238);
  pixels.setPixelColor(0, 178, 223, 238);
  
  pixels.setPixelColor(6, 191, 239, 255);
  pixels.setPixelColor(7, 191, 239, 255);
}


void loop() {  

int16_t i = random(MAXLED);

int16_t r = random(MAXCOLOR);

int16_t g = random(MAXCOLOR);

int16_t b = random(MAXCOLOR);

pixels.setPixelColor(i, r, g, b);

pixels.show();

delay(200);

}
My issues begin, when I try to address a Neopixel individually. If I comment out the content of the loop function and call shadesOfBlue() in setup nothing lights. If I try to just light one individual light nothing lights. The only time I can get an individual light to turn on is if, I first upload a sketch with the contents of loop function uncommented. Then upload another sketch, with just pixels.setPixelColor(7, 191, 239, 255) in my shadesOfBlue() uncommented. In this one instance the last light in my chain lights up. If I upload the exact same sketch a second time all lights turn off.

Is there something obvious I'm missing here?

User avatar
insultcomicdog
 
Posts: 25
Joined: Mon Apr 02, 2012 1:04 am

Re: WS2812B Problems Addressing Individual Neopixels

Post by insultcomicdog »

Ok I feel I'm getting close. I added pixels.show(); at the end of my shadesOfBlue() function and I can turn each light on individually....Except now all my lights are white and not a shade of blue like they are supposed to be. Any ideas why my colours aren't being set properly?

Code: Select all

void shadesOfBlue() {
  pixels.setPixelColor(1, 104, 131, 139);
  pixels.setPixelColor(2, 104, 131, 139);
  
  pixels.setPixelColor(3, 154, 192, 205);
  pixels.setPixelColor(4, 154, 192, 205);

  pixels.setPixelColor(5, 178, 223, 238);
  pixels.setPixelColor(0, 178, 223, 238);
  
  pixels.setPixelColor(6, 191, 239, 255);
  pixels.setPixelColor(7, 191, 239, 255);
  
  pixels.show();
}

User avatar
pburgess
 
Posts: 4161
Joined: Sun Oct 26, 2008 2:29 am

Re: WS2812B Problems Addressing Individual Neopixels

Post by pburgess »

Try running the strandtest example included with the NeoPixel library. Does it light the expected colors, or is that one going wonky as well?

User avatar
insultcomicdog
 
Posts: 25
Joined: Mon Apr 02, 2012 1:04 am

Re: WS2812B Problems Addressing Individual Neopixels

Post by insultcomicdog »

I trying running the strand test that ship with the NeoPixel library.

Seems to work fine:
https://vimeo.com/89611604

Here's my consolidated code block again (I should be seeing shades of blue. Instead all I see is white for each NeoPixel):

Code: Select all

#include <Adafruit_NeoPixel.h>

   

#define PIN 0

#define MAXLED 8

#define MAXCOLOR 255

   

Adafruit_NeoPixel pixels = Adafruit_NeoPixel(8, PIN);

void setup() {

pixels.begin();

pixels.setBrightness(83); // 1/3 brightness

pixels.show();

shadesOfBlue();

}

void shadesOfBlue() {
  pixels.setPixelColor(1, 104, 131, 139);
  pixels.setPixelColor(2, 104, 131, 139);
  
  pixels.setPixelColor(3, 154, 192, 205);
  pixels.setPixelColor(4, 154, 192, 205);

  pixels.setPixelColor(5, 178, 223, 238);
  pixels.setPixelColor(0, 178, 223, 238);
  
  pixels.setPixelColor(6, 191, 239, 255);
  pixels.setPixelColor(7, 191, 239, 255);
  
  pixels.show();
}


void loop() {  

//int16_t i = random(MAXLED);
//
//int16_t r = random(MAXCOLOR);
//
//int16_t g = random(MAXCOLOR);
//
//int16_t b = random(MAXCOLOR);
//
//pixels.setPixelColor(i, r, g, b);
//
//pixels.show();
//
//delay(200);

}

User avatar
grayconstruct
 
Posts: 12
Joined: Fri Feb 28, 2014 6:20 pm

Re: WS2812B Problems Addressing Individual Neopixels

Post by grayconstruct »

Keep in mind that when cutting down the brightness with setBrightness, you do loose resolution in your colors. so for example 1/3 brightness of RGB (192,239,255) produces (191/3, 239/3, 255/3) or (63, 79, 85).
Using a color picker like http://www.colorpicker.com/ your colors aren't very blue, they are mostly whitish blue to slate gray so I would not expect it to be very bluish. at the reduced brightness. try a color with reduced red and green channels like 31, 111, 253 or of course pure blue 0,0,255 and see how it looks.

User avatar
insultcomicdog
 
Posts: 25
Joined: Mon Apr 02, 2012 1:04 am

Re: WS2812B Problems Addressing Individual Neopixels

Post by insultcomicdog »

Thanks for the tips grayconstruct. You're right about brightness reducing resolution. I tried setting an individual NeoPixel to true blue and I could see a difference clearly. I picked the wrong colour range for my hello world app!

User avatar
insultcomicdog
 
Posts: 25
Joined: Mon Apr 02, 2012 1:04 am

Re: WS2812B Problems Addressing Individual Neopixels

Post by insultcomicdog »

I was cleaning up the wiring on my son's night light and something wonky started happening.

Using the Adafruit strip test, the animations now only run if I touch the output lead on the last NeoPixel in my daisy chain with my finger. If I remove my finger the animations stop.

Check out this behaviour here:

https://vimeo.com/89882319

I had the animations working fine last week (https://vimeo.com/89611604) with out touching the signal wire. The only difference in the setup now is that I connected the signal, ground and 5v wires of the top row of NeoPixels to the bottom row with actually hookup wire instead of temp gator clips.

Are you supposed to do anything special with the output lead on the last NeoPixel of a daisy chain? I tried rewiring twice now with the same results, which make it difficult to believe it's a bad splice somewhere.

User avatar
insultcomicdog
 
Posts: 25
Joined: Mon Apr 02, 2012 1:04 am

Re: WS2812B Problems Addressing Individual Neopixels

Post by insultcomicdog »

Found this in another thread:

"The resistor is a termination resistor to suppress ringing on the signal line. To be effective, it needs to be at the end of the line: http://en.wikipedia.org/wiki/Electrical_termination
The simplest way to do that is to solder the resistor to the strip and the signal line to the resistor (a bit of heat-shrink to protect the whole thing is a good idea too)."

Do I need to add a resistor to the output lead of the last NeoPixel? If yes, what value resistor do I need?

User avatar
adafruit_support_mike
 
Posts: 67446
Joined: Thu Feb 11, 2010 2:51 pm

Re: WS2812B Problems Addressing Individual Neopixels

Post by adafruit_support_mike »

That's a new one..

Could you post a photo of the wiring please? The state of the final DO pin shouldn't make any difference at all.

User avatar
insultcomicdog
 
Posts: 25
Joined: Mon Apr 02, 2012 1:04 am

Re: WS2812B Problems Addressing Individual Neopixels

Post by insultcomicdog »

Hi Mike,

I'll try and post a pic of the wiring tonight. Basically the signal wire, GRND and 5V are 22AWG solid hookup wire all running in parallel right next to each other in recessed channels on the top and bottom of this night light.

The GRND and 5V for the NeoPixels are supplied from external battery pack. The Trinket is powered by USB. Do I have to connect the GRND from the battery pack to the Trinket GRND?

The signal wire, the 5V and GRND are daisy chained separately. Any exposed connections were covered w heat shrink.

I did some more trouble shooting. I've discovered that if I touch the final DO lead, the 5V or the GRND my animations are smooth...If I let go of the leads the animations either get choppy or stop.

New video here:

https://vimeo.com/90088294

I tried shortening the distance to the first data in lead and attached another 5V lead further down stream. I still get the same flakey behaviour.

I'm going to try:

-adding a large capacitor (1000 µF, 6.3V or higher) across the + and – terminals
-adding a a 300 to 500 Ohm resistor between the Arduino data output pin and the input to the first NeoPixel

As a final resort I may break up the daisy chains and rewire the GRND, 5V and signal so they don't lay next to each other. I'd rather not have to do this, but I think somewhere in the circuit there's interference happening.

User avatar
davidl13
 
Posts: 187
Joined: Fri Oct 25, 2013 10:51 pm

Re: WS2812B Problems Addressing Individual Neopixels

Post by davidl13 »

insultcomicdog wrote:Hi Mike,
...
The GRND and 5V for the NeoPixels are supplied from external battery pack. The Trinket is powered by USB. Do I have to connect the GRND from the battery pack to the Trinket GRND?
...
I believe you need a common ground - try disconnecting USB and powering both from the battery.

User avatar
adafruit_support_bill
 
Posts: 88090
Joined: Sat Feb 07, 2009 10:11 am

Re: WS2812B Problems Addressing Individual Neopixels

Post by adafruit_support_bill »

Do I have to connect the GRND from the battery pack to the Trinket GRND?
Keep the ground from the battery pack connected to the NeoPixels GND. Then run a wire from the Trinket GND to the Neopixel GND.

User avatar
insultcomicdog
 
Posts: 25
Joined: Mon Apr 02, 2012 1:04 am

Re: WS2812B Problems Addressing Individual Neopixels

Post by insultcomicdog »

You guys rock. The common ground solved my issue. Animations are now buttery smooth. I didn't need a resistor or capacitor, and I'm super happy I don't have to rewire this thing! Thanks so much.

Locked
Please be positive and constructive with your questions and comments.

Return to “Glowy things (LCD, LED, TFT, EL) purchased at Adafruit”