Attiny85 - fastled - WS2812B leds

Hi, sorry if this is in the wrong forum, but it looked like the best place to post.

Currently I use an Arduino UNO, to test my code works and so I know the following works fine.

#include <FastLED.h> //load the fast led library into our program

#define DATA_PIN     1   // Connect the led strip data pin to this pin on the arduino nano controller.
#define LED_TYPE     WS2812B // These are the type of led strips we are using.
#define COLOR_ORDER GRB  // Changes the colour order if leds display incorrectly - can be RGB/BRG/GBR etc.
#define NUM_LEDS    59   // Number of LED's on our strip.
#define LED_Colour CRGB( 255, 0, 0) // Red,Green,Blue - values can be between 0-255.
#define SPEED       15    // How fast the colours move.  Lower numbers = faster motion.
#define TRAIL 80 // Length of red trail (0-254), lower numbers give a longer trail.
int BRIGHTNESS = 255;    // 0-255, higher number is brighter. 


CRGB leds[NUM_LEDS]; // This line creates a storage area to put our code in and uses the CRGB colour palette.

void setup() {
  delay(1000); // power-up safety delay (1 second) so the arduino can load the software before sending data to the led strips.
  FastLED.addLeds<LED_TYPE,DATA_PIN,COLOR_ORDER>(leds, NUM_LEDS).setCorrection(0xFFFFFF); //Set this so we know how to send data to the WS2812B leds.
  FastLED.setBrightness(BRIGHTNESS); //set led brightness when the first program loop starts.
}

void loop() { // This is the main code that runs continuously in a loop.
  colour_fade(); // call this routine
}

// Everything under here is functions called from the main void loop - add your own functions under this.

void colour_fade() {
        for(int dot = 0; dot < NUM_LEDS; dot++) { 
            leds[dot] = LED_Colour;
            FastLED.show(); // Show the red leds.
            fadeToBlackBy( leds, NUM_LEDS, TRAIL); // fade out the red leds for black so the leds look like they are moving.
            //leds[dot] = CRGB::Black; // don't fade out the leds to black, just make them black with no fade effect.
            delay(SPEED); // wait for xx nano seconds before the next loop starts.
        }
    }

Instead of using the uno - and due to the code being small - it can fit on the Attiny85.

On the Attiny85 - I've written the optiboot bootloader and set the fuses so the bootloader runs and the chip uses the internal oscillator at 8Mhz.

Low 0xE1
High 0xDD
Extended 0xFE

I can compile the blink code fine, and program the chip, test with an led - so I know that programming is not an issue and the chip works. I can also compile the above code and program that - but with the Attiny 85 - it's not working with the addressable Leds.

I think it could be down to some sort of timing issue and maybe I need to use a 16khz crystal - but I am just speculating here. I don't have any experience of using these small chips, but thought it would be fun to learn - but it's frustrating not knowing where I am going wrong. Does anyone know why the above code works with Arduino uno, but not with the Attiny85?

Which core for the ATTiny are you using? You should ALWAYS post that when asking about a microcontroller that is supported by a third party hardware package. In the case of the ATTiny85, there are many cores for it, which have significant differences.

Also, where did the version of FastLED that you're using come from? Always cite where you got libraries not included with the IDE - partly because of how easy it is to fork a repo in github, there are often dozens of slightly different versions of popular libraries floating around, often without the changes documented in any way. And old versions in zip files linked from tutorials.

I thought FastLED was supposed to work at 8MHz, and while the timing of the internal oscillator isn't guaranteed to be accurate (though at 3~5v and room temp, I've yet to find one that was very far off), the fact that you can upload to using a serial bootloader implies that this isn't the problem - the timing can't be off by much.

Thanks for the reply - I'm not sure what you mean by core. It's a standalone attiny 85 chip (not on a board).

I'm using arduino IDE - 1.8.7, and added this to boards manager:

http://digistump.com/package_digistump_index.json

Then for programming I select - Digispark 16/ or 8 Mghz no USB. Like I say, the Blink code works fine and the led blinks properly at 1 second intervals using (Delay 1000) - so the chip is being programmed properly using the optiboot bootloader.

Fastled library i'm using is from the official github page - version 3.2.1 by Daniel Garcia (http://fastled.io/). Fastled works fine using an arduino nano + arduino uno to control the addressable leds I'm using.

Is that info enough, or do you need to know anything else? Thanks.

Does that simplified test code work on Uno - just to be sure? Some things about it look strange, but I'm not an expert on FastLED.

Doesn't the digispark have the onboard LED on pin1? Could that be loading the output enough to interfere?

Can you use a different pin (not pins 3 or 4, because they've got those componetns for USB comms on them, or 5 because that's reset) (or remove the LED?)

Also - sanity check, how much ram do you have left? Does lowering the number of LEDs on the strip fix anything?
Does FastLED automatically set the pinMode to output? Try setting it output in setup()

Another thing to try, after moving the LEDs to another pin, have the sketch blink the onboard LED every second or something like that, in the same sketch as you're trying to drive the addressable LEDs. Also put a distinctive blink pattern in setup before you do anything with the LEDs. That way you can see if it's hanging or restarting (typically symptomatic of writing off the end of an array).

Hi,

Yes the code works fine on an Arduino Uno/Nano and Mega. (but not on the Attiny85).

I'm not using a Digispark - I'm using a stand alone chip, but yes the Digispark clone does have an led on pin 1 - that pin is PWM, so is Pin 0 - it makes no difference changing the data pin in the Arduino sketch though - the leds don't work on any pin that's assigned.

As for flash - the program is very small, and barely uses any ram/flash memory so should work fine.

Fast led works on other Arduino boards without setting pins as output - you only need to assign the data pin and led type and fastled takes care of the rest. The leds have chip on the strip so only need a data signal and common ground to work (apart from power of course).

Blink on the Attiny 85, works on whatever pin I assign in the sketch - so that's working fine.

I'm guessing I probably should go on the fastled forum and see if anyone else is having issues with this chip.

Thanks anyway, If I manage to find a solution I'll post my findings in here.

Did you ever resolve this problem?