Go Down

Topic: ATTiny85 w/ NeoPixels (Read 243 times) previous topic - next topic

TLAS

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>
#endif

#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);
  #endif
  // End of trinket special code
  pinMode(PIN,OUTPUT);
  strip.setBrightness(BRIGHTNESS);
  strip.begin();
  strip.show(); // Initialize all pixels to 'off'
  rainbowFade2White(3,3,1);
}


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

DrAzzy

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.
ATtiny core for 841+1634+828 and x313/x4/x5/x61/x7/x8 series Board Manager:
http://drazzy.com/package_drazzy.com_index.json
ATtiny breakouts (some assembled), mosfets and awesome prototyping board in my store http://tindie.com/stores/DrAzzy

TLAS

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.

DrAzzy

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....

ATtiny core for 841+1634+828 and x313/x4/x5/x61/x7/x8 series Board Manager:
http://drazzy.com/package_drazzy.com_index.json
ATtiny breakouts (some assembled), mosfets and awesome prototyping board in my store http://tindie.com/stores/DrAzzy

silly_cone

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?

Go Up