ws2812 Neopixels with attiny85

I’m running into some strange issues with my project. It seems that whenever I run the ws2812 LED at close to 5v, instead of changing to the assigned color, it briefly flashes said color and then goes black. However, if i run the LED at 3.3v all is fine. In addition to this, the problem only occurs when two color values are the same. For example an rgb value of 255, 255, 255 will produce the issue while 255, 0, 0 works fine. I’m using the adafruit neopixel library.

#include <Adafruit_NeoPixel.h>

#define PIN            1
#define NUMPIXELS      1

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

int delayval = 500;

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

void loop() {
  pixels.setPixelColor(0, pixels.Color(150,150,150));
  pixels.show();
  delay(delayval);
}

This code causes the LED to flash white every 500ms rather than stay white as it should. All help is appreciated!

You do know pin D1 is the TX pin try pin D2 What is the voltage measured on 5 volts? What power supply are you using? Show us how you have things wired. Place a 470uF capacitor near 5 volts and GND on the pixel.

What happens if you use: strip.setPixelColor(0, 150,150,150);

You do know the loop() function runs over and over again.

You are not by some chance trying to run the Arduino at 3.3V are you?

It should be noted that this code is running on an attiny85 and not an arduino. The tiny is good down to about 2.5v and pin 1 is an io pin. My fault for not making that clear.

But you did not answer my question.

I figured it out. Turns out the LED needs a 150 ohm resistor between the logic power supply pin and 5v. This explains why it worked fine at lower voltages.

Jsut210: I figured it out. Turns out the LED needs a 150 ohm resistor between the logic power supply pin and 5v. This explains why it worked fine at lower voltages.

So does that mean that your logic power supply is not 5V then. In which case your "solution" is subjecting the output pin on the attiny85 to greater than it's supply voltage and you are damaging it. You need a level shifter to make your small output data signal into a 5V signal for the LEDs.

Jsut210: I figured it out. Turns out the LED needs a 150 ohm resistor between the logic power supply pin and 5v.

Well, that is clearly absurd. You will never find that in any "tutorial".

It appears you are - and for some reason do not want to admit to it - running your microcontroller at 3.3V and trying to operate WS2811 pixels at 5V. The answer is - that is clearly wrong - you must operate both at the same voltage or perhaps as Mike suggests, use a level converter to drive the pixels.

What beats us, is why you are so reluctant to explain what you are doing. You clearly do not know what you are doing, so you are hardly going to "leak" valuable IP; the proper information can only benefit you.

A look at the ws2812 datasheet shows this: (my fault for mixing up 2811 and 2812)

I havn't given you any additional information and explained what I'm doing because I consider the issue resolved. Why waste the time to draw up a schematic and outline my project.

But because you are dying to know, both the tiny and the pixel was running off the same supply rail on the breadboard. All logic levels were the same at the supply voltage level. everything was either running off of 5v or 3.3v.

It is not just you it is others that read the thread.

The place where you show the resistors is in the decoupling of the chip's power supply. I would have thought that a large electrolytic across the supply would have done better. We're the caps you did use ceramic? If not maybe that is why you needed the resistor. It is most unusual, but not unknown to decouple like this only it is more usual to use a much lower resistor, something like a 47R or smaller.

Strangely a 10uF electrolytic cap did nothing like you said.

It is particularly inobvious as to why this particular chip requires decoupling at this point where others clearly do not as they most certainly do not include such, but it seems they must be exquisitely sensitive to switching transients.

It is absolutely normal to have a bypass capacitor on every NeoPixel irrespective of what "bulk" supply capacitor is fitted at the end - and no doubt for this very reason. And clearly the problem for which this decoupling is provided - on the WS2812 - is indeed "sensitive" as a lower voltage generates lower transients. We cannot argue that if the datasheet specifies it, there must be a reason.

The value of the resistor will not be critical because clearly this is for the logic supply whose current draw is presumably quite trivial - likely just tens or hundreds of microamps.

The value of the resistor will not be critical because clearly this is for the logic supply whose current draw is presumably quite trivial - likely just tens or hundreds of microamps.

You are correct, just about any resistor below 1k works.