Greetings everyone! I have been having a blast with NeoPixels and I have been

Greetings everyone!

I have been having a blast with NeoPixels and I have been using AdaFruit’s NeoPixel Library. It has some limitations but it works ok. I have been trying to get the FastLED Library working but to no avail. I am using ATTiny85s for my project for nothing but size. I love the features of FastLED but I think I need a little help. I know the ATTinys running at 8MHz do very well with the NeoPixels using the same library. What I want to do is switch over to using it instead but I am not having any success. Basically the LEDs will not light. If I do the same thing using the NeoPixel library, it works! I am just trying to use the RGBCalibrate sketch to get things going.

Any help will be greatly appreciated!

Thanks in advance!

Here is my sketch using FastLED:

#include “FastLED.h”

////////////////////////////////////////////////////////////////////////////////////////////////////
//
// RGB Calibration code
//
// Use this sketch to determine what the RGB ordering for your chipset should be. Steps for setting up to use:

// * Uncomment the line in setup that corresponds to the LED chipset that you are using. (Note that they
// all explicitly specify the RGB order as RGB)
// * Define DATA_PIN to the pin that data is connected to.
// * (Optional) if using software SPI for chipsets that are SPI based, define CLOCK_PIN to the clock pin
// * Compile/upload/run the sketch

// You should see six leds on. If the RGB ordering is correct, you should see 1 red led, 2 green
// leds, and 3 blue leds. If you see different colors, the count of each color tells you what the
// position for that color in the rgb orering should be. So, for example, if you see 1 Blue, and 2
// Red, and 3 Green leds then the rgb ordering should be BRG (Blue, Red, Green).

// You can then test this ordering by setting the RGB ordering in the addLeds line below to the new ordering
// and it should come out correctly, 1 red, 2 green, and 3 blue.
//
//////////////////////////////////////////////////

#define NUM_LEDS 6

// Data pin that led data will be written out over
#define DATA_PIN 0 // This is NOT the reset pin but PB0 which is physical pin 5 on the chip PDIP/SSOP
// Clock pin only needed for SPI based chipsets when not using hardware SPI
//#define CLOCK_PIN 8

CRGB leds[NUM_LEDS];

void setup() {
// sanity check delay - allows reprogramming if accidently blowing power w/leds
delay(2000);

FastLED.addLeds<NEOPIXEL, DATA_PIN, RGB>(leds, NUM_LEDS);
// Uncomment one of the following lines for your leds arrangement.
// FastLED.addLeds<TM1803, DATA_PIN, RGB>(leds, NUM_LEDS);
// FastLED.addLeds<TM1804, DATA_PIN, RGB>(leds, NUM_LEDS);
// FastLED.addLeds<TM1809, DATA_PIN, RGB>(leds, NUM_LEDS);
// FastLED.addLeds<WS2811, DATA_PIN, RGB>(leds, NUM_LEDS);
// FastLED.addLeds<WS2812, DATA_PIN, RGB>(leds, NUM_LEDS);
// FastLED.addLeds<WS2812B, DATA_PIN, RGB>(leds, NUM_LEDS);
// FastLED.addLeds<UCS1903, DATA_PIN, RGB>(leds, NUM_LEDS);

  // FastLED.addLeds<WS2801, RGB>(leds, NUM_LEDS);
  // FastLED.addLeds<SM16716, RGB>(leds, NUM_LEDS);
  // FastLED.addLeds<LPD8806, RGB>(leds, NUM_LEDS);

  // FastLED.addLeds<WS2801, DATA_PIN, CLOCK_PIN, RGB>(leds, NUM_LEDS);
  // FastLED.addLeds<SM16716, DATA_PIN, CLOCK_PIN, RGB>(leds, NUM_LEDS);
  // FastLED.addLeds<LPD8806, DATA_PIN, CLOCK_PIN, RGB>(leds, NUM_LEDS);

}

void loop() {
leds[0] = CRGB::Red;
leds[1] = CRGB::Green;
leds[2] = CRGB::Green;
leds[3] = CRGB::Blue;
leds[4] = CRGB::Blue;
leds[5] = CRGB::Blue;
FastLED.show();
delay(1000);
}

And here is the equivalent sketch using the NeoPixel library:

#include <Adafruit_NeoPixel.h>

#define DATAPIN 0
#define NUM_LEDS 6

// Parameter 1 = number of pixels in strip
// Parameter 2 = Arduino pin number (most are valid)
// Parameter 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)
Adafruit_NeoPixel rings = Adafruit_NeoPixel(NUM_LEDS, DATAPIN, NEO_GRB + NEO_KHZ800);
// IMPORTANT: To reduce NeoPixel burnout risk, add 1000 uF capacitor across
// pixel power leads, add 300 - 500 Ohm resistor on first pixel’s data input
// and minimize distance between Arduino and first pixel. Avoid connecting
// on a live circuit…if you must, connect GND first.

void setup() {
delay(2000);
rings.begin();
rings.show(); // Initialize all pixels to ‘off’
}

void loop() {
rings.setPixelColor(0, 0xFF0000);
rings.setPixelColor(1, 0x00FF00);
rings.setPixelColor(2, 0x00FF00);
rings.setPixelColor(3, 0x0000FF);
rings.setPixelColor(4, 0x0000FF);
rings.setPixelColor(5, 0x0000FF);
rings.show();
delay(1000);
}

Ok I do NOT know what happened, but I retried uploading the RGBCalibrate sketch on the ATTiny just to make sure that I did not miss anything and it WORKS! LOL

Previously I did try the other clockless variations and nothing worked before I posted!
Do not know what it was but it is working great!

Do you get any of the FastLED examples working on the ATTiny?

I remember seeing a post that there were some problems with clock less chips (like the ATTiny I think) with Arduino 1.0.6 (they rewrote the compile part). You might try it 1.0.5.

I am running 1.0.6 but I think I still have 1.0.5 on my other computer. I will give that a try and let you know. And an addtional update: It sometimes works when I reflash the bootloader then flash the sketch.
Thanks for the response and the info about 1.0.6. I will be testing that out today. :slight_smile:

Arduino 1.0.6 should be fine - it’s 1.5.8 that has problems. That said - part of the reason why resources are so tight on the ATTiny for FastLED vs. the adafruit library is that whole non-destructive, 0-overhead brightness/dithering/color correction going on :slight_smile:

Sadly, I blew out my trinket & gemma, and haven’t had a chance to replace them, so I haven’t gotten a look at what the code is doing on it most recently.

That said - the trinket/gemma are currently the only ATTiny85’s that are officially supported.

I tried both 1.0.5 and 1.0.6 with the sample code and it worked. One problem of my own doing was forgetting to change the data pin. The other was forgetting to unremark the addLeds line.
I tried adapting the NeoPixel strandtest sketch and was slightly successful. But I had some trouble with a modified version of colorWipe that works fine with the NeoPixel library but not with FastLED.

To keep it short the NeoPixel sample code uses uint32_t for its color data and uint8_t for some other parameters. When I saw those I thought maybe a byte was not enough so I changed the to uint16_t. This made the problem worse. When my sketch was running in the middle of the modified routine it would set on LED and the chip would reset. So I changed all the uint16 to int. Now it works as expected but the sketch is 30 bytes bigger. I will post some sample code from my computer. The only thing I can think of is that it must have something to do with how the compiler handles untyped constants. In my NeoPixel code I had to call a function for the number of LEDs in the strand. I just substituted the defined label NUM_LEDS for the function which was used in calculations. I think I am going to try a typed const and see what happens.

Hope this helps someone else because it was driving me crazy! LOL