ATTiny85 w/ NeoPixels

Hello everyone,

I’m having some trouble with an ATTiny85 running some Neopixel code. I’m using Arduino to compile the code (with the ATTiny85 boards loaded), but then using the MKII to program it through Atmel Studio 7. (The driver for Arduino is not compatible and I don’t want to loose another project I’m working in Atmel Studio).

The base issue is that I can’t get the Neopixel code to DO anything - I’m not registering any data communication from any of my pins. However, I can do digitalWrite and analogWrite just fine with some tests.

I’ve tried numerous modes with the frequency and fuse settings - no combination seems to make a difference. I can see the data when the device is being programmed, but whenever the Arduino code is supposed to be working, I just get nothing… everywhere…

Here’s the basis of the code:

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

#define PIN PB0

#define NUM_LEDS 144

#define BRIGHTNESS 10

Adafruit_NeoPixel strip = Adafruit_NeoPixel(NUM_LEDS, PIN, NEO_GRBW + 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);
// End of trinket special code
strip.begin();; // Initialize all pixels to ‘off’

Any thoughts? When I’m running analogWrite tests and looking at the PWM, the frequency looks fine (+/- ~1%)

When you change the frequency setting, did you remember to do "burn bootloader"? Otherwise, these settings will not be applied, and your attiny will still be running at the speed it previously was set to. If using a crystal, you need a crystal of the correct frequency connected.

When you upload blink, does the LED blink at the correct frequency? If not, that indicates that it is running at a different speed from what you have selected in the IDE, which will prevent any neopixel code from working.

I’m actually burning the setting from Atmel Studio. But yes, the frequency looks correct when I run rear code samples (within about 1%). It really just looks like the neopixel code isn’t using the pins and getting lost somewhere.

I'll bet your problem is trying to control too many LEDs for the memory on the tiny85. 144 LEDs is 432 bytes just for the frame buffer. It doesn't take much else to run out of memory, and with the low resources on an attiny, there isn't a good way to detect that. So it's probably failing (or partly failing) due to insufficient memory....

What clock speed are you running at? You may have already ruled this out by clocking your PWM, but I've had trouble with the attiny85 and the FastLED library in the past if the clock-speed was too slow (or at least I was having a problem that consistently became fixed by upping the clock speed with the core I was using at the time).

So double-check that your fuses actually are set where you think they are, and that you've selected the correct, sufficiently-fast clock-speed in the arduino IDE before compiling and flashing.

Also, in Atmel, are you flashing the hex file that ends only .ino.hex NOT the .ino.with_bootloader.hex file?