0

ATTiny85/WS2812B Running Neopixel Strand Test Code
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

ATTiny85/WS2812B Running Neopixel Strand Test Code

by akfreak on Fri Feb 27, 2015 8:01 pm

I was at https://github.com/adafruit/Adafruit_NeoPixel/ when I posted anissue looking for help tdicola commented, "Try posting in the forums at http://forums.adafruit.com/, "there are more folks that might be able to help troubleshoot your setup. Thanks!" Then closed the topic.

I see this is a "For Customers Forum" I did not buy my components from Adafruit, and when trying to work with the Adafruit Github library Examples, I cant make them work.

Before I post my problem, will I get any help here?

akfreak
 
Posts: 6
Joined: Fri Feb 27, 2015 7:50 pm

Re: ATTiny85/WS2812B Running Neopixel Strand Test Code

by akfreak on Sat Feb 28, 2015 12:37 am

Well. I guess Ill ask anyways,

I have everything set up and I upload the code to the ATTIny85, then I plug in the strip, and the only LED that lights up is the first one. The first LED lights green then it turns Yellow and stays yellow. This means I am at least pushing code to the ATTiny85, and my settings are right in the Ardunio software (1.6.0), however somthing is wrong
Code: Select all | TOGGLE FULL SIZE
#include <Adafruit_NeoPixel.h>
#include <avr/power.h>

#define PIN 3

// 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 strip = Adafruit_NeoPixel(20, PIN, 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() {
  // This is for Trinket 5V 16MHz, you can remove these three lines if you are not using a Trinket

  // End of trinket special code


  strip.begin();
  strip.show(); // Initialize all pixels to 'off'
}

void loop() {
  // Some example procedures showing how to display to the pixels:
  colorWipe(strip.Color(255, 0, 0), 50); // Red
  colorWipe(strip.Color(0, 255, 0), 50); // Green
  colorWipe(strip.Color(0, 0, 255), 50); // Blue
  // Send a theater pixel chase in...
  theaterChase(strip.Color(127, 127, 127), 50); // White
  theaterChase(strip.Color(127,   0,   0), 50); // Red
  theaterChase(strip.Color(  0,   0, 127), 50); // Blue

  rainbow(20);
  rainbowCycle(20);
  theaterChaseRainbow(50);
}

// Fill the dots one after the other with a color
void colorWipe(uint32_t c, uint8_t wait) {
  for(uint16_t i=0; i<strip.numPixels(); i++) {
      strip.setPixelColor(i, c);
      strip.show();
      delay(wait);
  }
}

void rainbow(uint8_t wait) {
  uint16_t i, j;

  for(j=0; j<256; j++) {
    for(i=0; i<strip.numPixels(); i++) {
      strip.setPixelColor(i, Wheel((i+j) & 255));
    }
    strip.show();
    delay(wait);
  }
}

// Slightly different, this makes the rainbow equally distributed throughout
void rainbowCycle(uint8_t wait) {
  uint16_t i, j;

  for(j=0; j<256*5; j++) { // 5 cycles of all colors on wheel
    for(i=0; i< strip.numPixels(); i++) {
      strip.setPixelColor(i, Wheel(((i * 256 / strip.numPixels()) + j) & 255));
    }
    strip.show();
    delay(wait);
  }
}

//Theatre-style crawling lights.
void theaterChase(uint32_t c, uint8_t wait) {
  for (int j=0; j<10; j++) {  //do 10 cycles of chasing
    for (int q=0; q < 3; q++) {
      for (int i=0; i < strip.numPixels(); i=i+3) {
        strip.setPixelColor(i+q, c);    //turn every third pixel on
      }
      strip.show();
     
      delay(wait);
     
      for (int i=0; i < strip.numPixels(); i=i+3) {
        strip.setPixelColor(i+q, 0);        //turn every third pixel off
      }
    }
  }
}

//Theatre-style crawling lights with rainbow effect
void theaterChaseRainbow(uint8_t wait) {
  for (int j=0; j < 256; j++) {     // cycle all 256 colors in the wheel
    for (int q=0; q < 3; q++) {
        for (int i=0; i < strip.numPixels(); i=i+3) {
          strip.setPixelColor(i+q, Wheel( (i+j) % 255));    //turn every third pixel on
        }
        strip.show();
       
        delay(wait);
       
        for (int i=0; i < strip.numPixels(); i=i+3) {
          strip.setPixelColor(i+q, 0);        //turn every third pixel off
        }
    }
  }
}

// Input a value 0 to 255 to get a color value.
// The colours are a transition r - g - b - back to r.
uint32_t Wheel(byte WheelPos) {
  WheelPos = 255 - WheelPos;
  if(WheelPos < 85) {
   return strip.Color(255 - WheelPos * 3, 0, WheelPos * 3);
  } else if(WheelPos < 170) {
    WheelPos -= 85;
   return strip.Color(0, WheelPos * 3, 255 - WheelPos * 3);
  } else {
   WheelPos -= 170;
   return strip.Color(WheelPos * 3, 255 - WheelPos * 3, 0);
  }
}


Here is a pastbin the code.. http://pastebin.com/W9vDHXMz
Last edited by akfreak on Sat Feb 28, 2015 12:52 am, edited 2 times in total.

akfreak
 
Posts: 6
Joined: Fri Feb 27, 2015 7:50 pm

Re: ATTiny85/WS2812B Running Neopixel Strand Test Code

by franklin97355 on Sat Feb 28, 2015 12:47 am


franklin97355
 
Posts: 20753
Joined: Mon Apr 21, 2008 2:33 pm
Location: Lacomb, OR.

Re: ATTiny85/WS2812B Running Neopixel Strand Test Code

by pburgess on Sat Feb 28, 2015 1:33 am

Possibly CPU frequency-releated. For example, on the Trinket board (ATtiny85-based), it's necessary to manually set the prescaler for 16 MHz operation:
Code: Select all | TOGGLE FULL SIZE
#ifdef __AVR_ATtiny85__ // Trinket, Gemma, etc.
  if(F_CPU == 16000000) clock_prescale_set(clock_div_1);
#endif

Otherwise the code *thinks* it's on a 16 MHz board, but really runs at 8 MHz, and the NeoPixel timing is all off.

pburgess
 
Posts: 4022
Joined: Sun Oct 26, 2008 2:29 am

Re: ATTiny85/WS2812B Running Neopixel Strand Test Code

by akfreak on Sat Feb 28, 2015 3:31 am

Now I really am confused. I know the Trinket uses an attiny85, however I thought I could use the strandtest code to talk to my strand of RGB leds.

Edit..

I spoke to someone about this project, and he told me this said, "
"So the one thing that I almost always end up having to poke at is the Pin definition. I think Arduino managed to confuse things by adding yet another label to the pin - we already had the physical pin number and the chip interface pin number, and arduino obfuscates it even more. And then I don’t help myself by standardizing my libraries or my boards, they tend to be sort of “which disused pin is easiest to route?” So cycle through those, but it sounds like it’s getting power. I _think_ the WS2812 driver will just blink and lock at a color when it gets power but nothing on DI to tell it what else to do, although it’s been a while since I experimented with the failure modes."

I asked him what he meant by change the pin definition, this is what he said,

"Oh, no, I mean D1-D5 since VCC/GND/RST take up the other 3 pins. The only other thing that might need tweaking is to set the er uh what’re those called, uh. Clock rate and other settings on the chip. I usually copy my makefile around so everything gets tweaked, but it’s possible you aren’t clocking bits out fast enough at the default speed.

This bit of avrdude:

avrdude -c usbasp \
-C /Applications/Arduino.app/Contents/Resources/Java/hardware/tools/avr/etc/avrdude.conf \
-p t85 \
-U lfuse:w:0xc1:m \
-U hfuse:w:0xd7:m \
-U efuse:w:0xff:m \
-U flash:w:WS2812_strip_simple.hex:i"

I dont understand what he is trying to say. Also I cant find a single tutorial that shows the actual Neopixel standtest code working on a Attiny85. I saw the blink code tutorial, but thats is it. Thanks for trying to help me, I am kind of confused as to what I need to do to use the standard Strandtest code with my attiny85

akfreak
 
Posts: 6
Joined: Fri Feb 27, 2015 7:50 pm

Re: ATTiny85/WS2812B Running Neopixel Strand Test Code

by franklin97355 on Sat Feb 28, 2015 6:53 pm

Have you tried running any of the Trinket and Neopixel code on the learning site yet?

franklin97355
 
Posts: 20753
Joined: Mon Apr 21, 2008 2:33 pm
Location: Lacomb, OR.

Re: ATTiny85/WS2812B Running Neopixel Strand Test Code

by akfreak on Sat Feb 28, 2015 11:38 pm

The only code I have tried running is the NeoPixel Example code, "strand test" . In that code it says if you aren't using trinket to strip out the three lines of code.

I am not one to go blindly trying to run different this or that. When after I tried to use a default code that was designed as an example to run an LED strip, and achieve limited results (one led light up and changes color), I want to research to find what I am doing wrong.

Also I want to say thank you so very much for trying to help me. At this point I will look to the learning site and try a bunch of different stuff and just hope I get lucky and find a code set that works.

I was really hoping for someone to peek at the strandtest code and tell me what is wrong, is I can actually learn something.

akfreak
 
Posts: 6
Joined: Fri Feb 27, 2015 7:50 pm

Re: ATTiny85/WS2812B Running Neopixel Strand Test Code

by akfreak on Sun Mar 01, 2015 1:40 am

Ok.. Ok.. Ok... I got it.. I was missing a step. The default strand test code works perfect. Even with the Trinket code removed. Thanks for your willing to help me even though I am not a paying customer. I am excited, now I can figure out the code, and change it the way I want to look. Whoo, Hooo.! MAn this is cool stuff.

I built a tiny board attiny85 board. Its tiny.. I got it made at OSHpark. I have the pin headers on it now I can make the LEDS finally work Man what a night. The project came to life.

akfreak
 
Posts: 6
Joined: Fri Feb 27, 2015 7:50 pm

Re: ATTiny85/WS2812B Running Neopixel Strand Test Code

by franklin97355 on Sun Mar 01, 2015 11:06 pm

Glad to hear you got it working. Was it something in the demo code that was causing your problem?

franklin97355
 
Posts: 20753
Joined: Mon Apr 21, 2008 2:33 pm
Location: Lacomb, OR.

Re: ATTiny85/WS2812B Running Neopixel Strand Test Code

by akfreak on Mon Mar 02, 2015 3:31 am

No, it is somthing you have to do when using a ATtiny85.. That is to config the fuse settings.. You can find this info here http://www.engbedded.com/fusecalc/.. Find the attiny85 from the dropdown, then you can configure it. I have not worked with attiny before, now I know exactly what to do. The code is perfect.

akfreak
 
Posts: 6
Joined: Fri Feb 27, 2015 7:50 pm

Re: ATTiny85/WS2812B Running Neopixel Strand Test Code

by ramsbod on Sat Jul 11, 2015 4:28 pm

I am trying to get the Neopixel Strandtest to work on the Attiny84. The code works fine on the Arduino Uno and loads fine onto the Attiny 84 but none of the pixels work. I suspect it has something to do with the clock speed. The code won't load with a clock speed of 1MHz. I ran to bootloader to change the clock speed to 8MHz but none of the pixels light up at all. Will the strandtest work at a clockspeed of 8MHz. You mentioned setting the fuses correctly. I went to the link you posted but I don't undertand how to go about it. Please help.

ramsbod
 
Posts: 1
Joined: Sat Jul 11, 2015 4:18 pm

Re: ATTiny85/WS2812B Running Neopixel Strand Test Code

by fredericaltorres on Sun Sep 27, 2015 10:56 pm

I have the same problem than you. trying to program an ATtiny85 directly to control 7 neopixel led.
I understand I may need to change the fuse.
How I do understand how to do it.

fredericaltorres
 
Posts: 31
Joined: Fri Feb 07, 2014 10:30 am

Re: ATTiny85/WS2812B Running Neopixel Strand Test Code

by franklin97355 on Mon Sep 28, 2015 1:25 am

@fredericaltorres have you tried the tutorial on running Neopixels with the Trinket or Gemma? https://learn.adafruit.com/led-masquerade-masks and others.

franklin97355
 
Posts: 20753
Joined: Mon Apr 21, 2008 2:33 pm
Location: Lacomb, OR.

Re: ATTiny85/WS2812B Running Neopixel Strand Test Code

by Alex_W on Sat Nov 07, 2015 12:34 am

I had the exact same issue getting this to work. To set the fuses properly in the Arduino IDE you need to select 'Burn Bootloader'.
After that all problems were solved!
Alex_W
 
Posts: 2
Joined: Fri Apr 06, 2012 6:42 pm

Re: ATTiny85/WS2812B Running Neopixel Strand Test Code

by pmidthun on Tue Sep 20, 2016 10:33 am

Hello, i am a paying adafruit customer and I found this helpful, I also needed to "burn bootloader" to get the Attiny85 I was using without a board to correctly run the neopixels. Attached are the settings I used.
Attachments
Attiny85 settings.png
Attiny85 settings.png (136.67 KiB) Viewed 2500 times

pmidthun
 
Posts: 10
Joined: Fri Jul 24, 2015 10:23 am

Please be positive and constructive with your questions and comments.