🎁📬❄️📦Adafruit Holiday Shipping Deadlines 2019: Please place all UPS 2 Day orders by 11am Monday, December 16 📦❄️📬🎁
0

Unexpected colors with neopixels coded to flicker
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

Unexpected colors with neopixels coded to flicker

by devsfan1830 on Mon Dec 02, 2019 7:33 pm

I have a project using 6 NeoPixel Mini Button PCB's. It's a stand for some Kyber Crystals I bought from a visit to Star Wars: Galaxies Edge in Disneyland. The code is written such hat each neopixel is fixed to a specific color (white, blue, green, yellow, purple, red) so that the light that shines up matches each crystal. Then, each time the main loop runs, 6 radom number generators run. Each value is used for the RGB code of each LED, such that they all randomly flicker with a random "brightness" but since one random number is assigned to all the respective RGB positions for that LED, the color is supposed to stay a shade of the default color. However, I'm getting frequent glitches where any of the given neopixels flash the wrong color. The code, although probably crude, seems pretty much solid. But I'm not sure whats going on. Maybe I am exceeding the color switch response time of the LEDs? Any ideas how I can fix this or IF i can fix this?

Powered via 5V 2.5A microUSB power adapter and driven with an arduino nano.

Image of wiring:

Image

Code:

Code: Select all | TOGGLE FULL SIZE
// A basic everyday NeoPixel strip test program.

// NEOPIXEL BEST PRACTICES for most reliable operation:
// - Add 1000 uF CAPACITOR between NeoPixel strip's + and - connections.
// - MINIMIZE WIRING LENGTH between microcontroller board and first pixel.
// - NeoPixel strip's DATA-IN should pass through a 300-500 OHM RESISTOR.
// - AVOID connecting NeoPixels on a LIVE CIRCUIT. If you must, ALWAYS
//   connect GROUND (-) first, then +, then data.
// - When using a 3.3V microcontroller with a 5V-powered NeoPixel strip,
//   a LOGIC-LEVEL CONVERTER on the data line is STRONGLY RECOMMENDED.
// (Skipping these may work OK on your workbench but can fail in the field)

#include <Adafruit_NeoPixel.h>
#ifdef __AVR__
 #include <avr/power.h> // Required for 16 MHz Adafruit Trinket
#endif

// Which pin on the Arduino is connected to the NeoPixels?
// On a Trinket or Gemma we suggest changing this to 1:
#define LED_PIN    2

// How many NeoPixels are attached to the Arduino?
#define LED_COUNT 6

// Declare our NeoPixel strip object:
Adafruit_NeoPixel strip(LED_COUNT, LED_PIN, NEO_GRB + NEO_KHZ800);
// Argument 1 = Number of pixels in NeoPixel strip
// Argument 2 = Arduino pin number (most are valid)
// Argument 3 = Pixel type flags, add together as needed:
//   NEO_KHZ800  800 KHz bitstream (most NeoPixel products w/WS2812 LEDs)
//   NEO_KHZ400  400 KHz (classic 'v1' (not v2) FLORA pixels, WS2811 drivers)
//   NEO_GRB     Pixels are wired for GRB bitstream (most NeoPixel products)
//   NEO_RGB     Pixels are wired for RGB bitstream (v1 FLORA pixels, not v2)
//   NEO_RGBW    Pixels are wired for RGBW bitstream (NeoPixel RGBW products)


// setup() function -- runs once at startup --------------------------------

void setup() {
  // These lines are specifically to support the Adafruit Trinket 5V 16 MHz.
  // Any other board, you can remove this part (but no harm leaving it):
#if defined(__AVR_ATtiny85__) && (F_CPU == 16000000)
  clock_prescale_set(clock_div_1);
#endif
  // END of Trinket-specific code.

  strip.begin();           // INITIALIZE NeoPixel strip object (REQUIRED)
  strip.show();            // Turn OFF all pixels ASAP
  strip.setBrightness(150); // Set BRIGHTNESS to about 1/5 (max = 255)
 
 
  }


// loop() function -- runs repeatedly as long as board is on ---------------

void loop() {

 
  int white = random(100,255);
  int blue = random(100,255);
  int green = random(100,255);
  int yellow = random(100,255);
  int purple = random(100,255);
  int red = random(100,255);

 
  strip.setPixelColor(0,white,white,white);         //  White
  strip.setPixelColor(1,0,0,blue);         //  Blue
  strip.setPixelColor(2,0,green,0);         //  Green
  strip.setPixelColor(3,yellow,yellow,0);         //  Yellow
  strip.setPixelColor(4,purple,0,purple);         //  Purple
  strip.setPixelColor(5,red,0,0);         //  Red
  strip.show();
  delay(50);



}


Video of an example of the glitch: https://youtu.be/aa5UYed0FuM

devsfan1830
 
Posts: 56
Joined: Sat Feb 07, 2015 11:36 pm

Re: Unexpected colors with neopixels coded to flicker

by adafruit_support_bill on Mon Dec 02, 2019 8:03 pm

Led response is not linear and not all of the color channels respond equally - especially at lower power levels. The red channel in particular tends to be more responsive at lower power levels which likely explains the brief red flicker in the white crystal near the end of the video clip.

adafruit_support_bill
 
Posts: 75326
Joined: Sat Feb 07, 2009 10:11 am

Re: Unexpected colors with neopixels coded to flicker

by kcl1s on Mon Dec 02, 2019 8:13 pm

A couple of things. The update rate on the video is much slower than the 20 refreshes/sec the delay(50); gives you. I assume you modified the code for the video. Second you only show the white and blue pixels is the white one the only one giving you problems? I ran the code on a strip and did not see any glitches. I would suspect the #0 pixel might be bad. Another possibility if you are truly running the code at delay(50); is that the signal wire is making intermittent contact, maybe in the black connector.

Fellow hobbyist
Keith

kcl1s
 
Posts: 1365
Joined: Tue Aug 30, 2016 12:06 pm

Re: Unexpected colors with neopixels coded to flicker

by devsfan1830 on Mon Dec 02, 2019 8:49 pm

So here’s something interesting. I connected via USB to the Arduino directly which, due to my wiring also powers the LEDS. The glitching is entirely gone. However, if i use the USB power supply via my microusb board, it begijs color glitching immediately. Ive tried different USB a to microusb chargers i have and all show the glitching.

devsfan1830
 
Posts: 56
Joined: Sat Feb 07, 2015 11:36 pm

Re: Unexpected colors with neopixels coded to flicker

by devsfan1830 on Mon Dec 02, 2019 8:52 pm

kcl1s wrote:A couple of things. The update rate on the video is much slower than the 20 refreshes/sec the delay(50); gives you. I assume you modified the code for the video. Second you only show the white and blue pixels is the white one the only one giving you problems? I ran the code on a strip and did not see any glitches. I would suspect the #0 pixel might be bad. Another possibility if you are truly running the code at delay(50); is that the signal wire is making intermittent contact, maybe in the black connector.

Fellow hobbyist
Keith


Actually no code modification. I used my iPhones slo-mo to show the color flashes better.

devsfan1830
 
Posts: 56
Joined: Sat Feb 07, 2015 11:36 pm

Re: Unexpected colors with neopixels coded to flicker

by kcl1s on Mon Dec 02, 2019 9:09 pm

Actually no code modification. I used my iPhones slo-mo to show the color flashes better.

Got it.

I believe that by routing raw 5v from the adapter to the 5v pin on the Nano you are bypassing the filter capacitors and a Schottky diode that the onboard USB connector uses to give smooth 5v power. The 5v pin is usually used for 5 volts out.

Keith

kcl1s
 
Posts: 1365
Joined: Tue Aug 30, 2016 12:06 pm

Re: Unexpected colors with neopixels coded to flicker

by devsfan1830 on Mon Dec 02, 2019 9:39 pm

Sounds about right. Ive powered via 5V on other projects and none of them seem to have had any issue but maybe its because they didnt flicker LEDS like this. My only other neopixel project i have sets a static color on an entire strip. One mode makes the whole strip slowly pulse via the setbrightness command which probably isnt ideal but its worked for a few years now. Its that, an arduino uno and audiofx board all tied to their 5v pins and powered off my PC PSU. For something like this ill just go ahead and modify my 3d print to narrow the hole for a usb wire and just plug into the arduino that way.

devsfan1830
 
Posts: 56
Joined: Sat Feb 07, 2015 11:36 pm

Please be positive and constructive with your questions and comments.