0

Trinket inconsistent behaviour with Neopixels
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

Trinket inconsistent behaviour with Neopixels

by jw1942 on Mon Jan 21, 2019 1:30 pm

Hi,

I've put together a project which uses 3 individual Neopixels (5050). They are all supposed to fade up from 0 to full brightness (setup) and then flicker constantly (loop). The script I wrote works perfectly every time on an Arduino Uno board, but when I put it on my trinket (3.3v) it is inconsistent. It sometimes works perfectly, sometimes the Neopixels don't light up at all, sometimes they light up without the fade up and they flicker, sometimes they light up a slightly dim greenish colour instead of white. Sometimes they will fade up, start flickering and then stop after a minute or so.

The red LED on the trinket sometimes comes on when I power it on and sometimes doesn't, sometimes it comes on briefly and then goes off, and sometimes it continues to flash intermittently. Is this an issue with the trinket failing to transmit to the Neopixels? If so is there any explanation for the inconsistency?

FYI I have tried various power sources for the trinket including USB, 4,5v battery pack and 3,7v battery pack.

Code: Select all | TOGGLE FULL SIZE

#include <avr/power.h>
#include <Adafruit_NeoPixel.h>

#define PIN 2  // engine warm-up activate pin

unsigned long previousMillis1 = 0;
unsigned long previousMillis2 = 0;
unsigned long previousMillis3 = 0;
unsigned long interval = 120;

Adafruit_NeoPixel strip = Adafruit_NeoPixel(1, PIN, NEO_GRB + NEO_KHZ800);

void setup() {
  // This is for Trinket 5V 16MHz, you can remove these three lines if you are not using a Trinket
#if defined (__AVR_ATtiny85__)
  if (F_CPU == 16000000) clock_prescale_set(clock_div_1);
#endif
  // End of trinket special code
  strip.begin();

  //strip.setPixelColor(0, 20, 0, 255); // pixel color set to ?
  //strip.show();
 
  // Begin Engine Warmup

  int i = 0;
  int c = 255;

  do {
    i = i + 1;
    c = c - 1;
    strip.setPixelColor(0, 198, 198, 255); // set pixel color to white/blue
    strip.show();
    delay(0); // speed of color change
    strip.setBrightness(0 + i); // brings up brightness from 0 to full
    strip.show();
    delay (15); // speed of brightening
  } while (i < 255, c > 0);

  //delay(1500);
}

void loop() {
  // put your main code here, to run repeatedly:

  // Begin Engine Flicker

  strip.setBrightness(random(125, 255)); // random brightness adjust for flicker effect
  strip.show();
  unsigned long currentMillis2 = millis(); // random time adjust for brightness
  if (currentMillis2 - previousMillis2 > (random(500, 750))) {
    previousMillis2 = currentMillis2;
  }

}


jw1942
 
Posts: 4
Joined: Mon Jan 21, 2019 1:23 pm

Re: Trinket inconsistent behaviour with Neopixels

by adafruit_support_carter on Mon Jan 21, 2019 3:29 pm

NeoPixels are really 5V devices, so may be marginal at 3.3V.
https://learn.adafruit.com/neopixel-lev ... ing-levels

adafruit_support_carter
 
Posts: 9701
Joined: Tue Nov 29, 2016 2:45 pm

Re: Trinket inconsistent behaviour with Neopixels

by jw1942 on Mon Jan 21, 2019 3:56 pm

Thanks for the response. I’ve just tried substituting the 3,3v Trinket for a 5v Pro Trinket and I get the same results - most often then neopixels don’t light up at all

jw1942
 
Posts: 4
Joined: Mon Jan 21, 2019 1:23 pm

Re: Trinket inconsistent behaviour with Neopixels

by adafruit_support_carter on Mon Jan 21, 2019 3:58 pm

Post a photo of your setup showing how everything is connected.

adafruit_support_carter
 
Posts: 9701
Joined: Tue Nov 29, 2016 2:45 pm

Re: Trinket inconsistent behaviour with Neopixels

by jw1942 on Mon Jan 21, 2019 5:26 pm

I'm struggling to get a photo that is below the 1mb limit, but I can describe it:

Neopixel data in: all three connected to Pin 2
Neopixel +ve: all three connected to BAT+ (or 3v, I get the same result)
Neopixel -ve: all three connected to GND (next to BAT+)
Trinket +ve pad under the USB is connected to the BAT of an Adafruit Microlipo charger
Trinket -ve pad under the USB is connected to the GND of an Adafruit Microlipo charger
Adafruit Microlipo is connected to battery using JST

jw1942
 
Posts: 4
Joined: Mon Jan 21, 2019 1:23 pm

Re: Trinket inconsistent behaviour with Neopixels

by adafruit_support_carter on Mon Jan 21, 2019 9:20 pm

Neopixel data in: all three connected to Pin 2

NeoPixels are chained, not all connected to the same spot. The data out from one goes to the data in of the next, and so on.

adafruit_support_carter
 
Posts: 9701
Joined: Tue Nov 29, 2016 2:45 pm

Re: Trinket inconsistent behaviour with Neopixels

by jw1942 on Tue Jan 22, 2019 12:05 pm

That is understood. But assuming you want the same data to go to each pixel is there a reason you shouldn't attach multiple Neopixels to one pin?

jw1942
 
Posts: 4
Joined: Mon Jan 21, 2019 1:23 pm

Re: Trinket inconsistent behaviour with Neopixels

by adafruit_support_carter on Tue Jan 22, 2019 12:44 pm

Hmmm. Yah, you could do that.

Try using this service to scale your images down:
https://cloudconvert.com/
and see if you can get them to post.

adafruit_support_carter
 
Posts: 9701
Joined: Tue Nov 29, 2016 2:45 pm

Re: Trinket inconsistent behaviour with Neopixels

by Blueshark on Tue Jan 22, 2019 11:14 pm

jw1942 ……….. have you tried using an 2D Array's [ ] in your code to control the pixels at the same time?


This guide explains about 2D Array's with Neopixels....


https://learn.adafruit.com/ledshades/software-and-bluetooth-control-1



Cheers...

Blueshark
 
Posts: 98
Joined: Thu Dec 21, 2017 7:19 pm

Please be positive and constructive with your questions and comments.