Two Neopixel strips on two separate pins. Works on Arduino but not on Attiny45..

Hi!

I just bought a pair of 8 pixel Neopixel strips. These are for my girlfriends christmas party, to be ear rings. I just altered an example program a bit. It all worked fine on a Arduino uno using pin 7 and 8. I then made a little board with an Attiny45. Now only the strip on pin 0 works, not the one on pin 1. Ive changed the define in the code of the pins, so switching the variables pin 1 works but not pin 0. So it’s not a soldering error atleast :slight_smile:

What could it be? Anyone experienced this? Code below:

#define F_CPU 8000000L

#include <Adafruit_NeoPixel.h>
#ifdef __AVR__
  #include <avr/power.h>
#endif

#define PINV 1
#define PINH 0

Adafruit_NeoPixel stripV = Adafruit_NeoPixel(8, PINV, NEO_GRB + NEO_KHZ800);
Adafruit_NeoPixel stripH = Adafruit_NeoPixel(8, PINH, NEO_GRB + NEO_KHZ800);

void setup() {
  pinMode(0, OUTPUT);
  pinMode(1, OUTPUT);
  
  stripV.begin();
  stripV.show(); // Initialize all pixels to 'off'
  stripV.setBrightness(24);
  stripH.begin();
  stripH.show(); // Initialize all pixels to 'off'
  stripH.setBrightness(20);
}

void loop() {
   for (int c=0; c<4; c++) { rainbow(15); }
      colorWipe(stripV.Color(0, 0, 0), 100); 
   for (int c=0; c<2; c++) { 
      colorWipe(stripV.Color(255, 0, 0), 100);
       colorWipe(stripV.Color(0, 0, 0), 100); 
      colorWipeBakoFram(stripV.Color(0, 255, 0), 100); 
       colorWipeBakoFram(stripV.Color(0, 0, 0), 100); 
      colorWipe(stripV.Color(255, 0, 0), 100);
       colorWipe(stripV.Color(0, 0, 0), 100); 
      colorWipeBakoFram(stripV.Color(0, 255, 0), 100);
       colorWipeBakoFram(stripV.Color(0, 0, 0), 100);   
      colorWipe(stripV.Color(0, 0, 255), 100);
       colorWipe(stripV.Color(0, 0, 0), 100); 
      colorWipeBakoFram(stripV.Color(0, 0, 255), 100);
       colorWipeBakoFram(stripV.Color(0, 0, 0), 100); 
//      colorWipeBakoFram(stripV.Color(255, 0, 0), 100); 
//      colorWipeBakoFram(stripV.Color(0, 255, 0), 100); 
//      colorWipeBakoFram(stripV.Color(0, 0, 255), 100);
    //  colorWipeBakoFram(stripV.Color(0, 0, 0), 100);  
   } 

   theaterChaseRainbow(150);
   
   colorWipe(stripV.Color(0, 0, 0), 100);

   for (int c=0; c<5; c++) { rainbowCycle(4); }
   
   colorWipe(stripV.Color(0, 0, 0), 100);

   theaterChase(stripV.Color(0, 127, 0), 5); 
   theaterChase(stripV.Color(127, 0, 0), 5);
      theaterChase(stripV.Color(0, 127, 0), 5); 
   theaterChase(stripV.Color(127, 0, 0), 5);
      theaterChase(stripV.Color(0, 127, 0), 5); 

   
   colorWipe(stripV.Color(0, 0, 0), 100);
}

// Fill the dots one after the other with a color
void colorWipe(uint32_t c, uint8_t wait) {
  int a = 8;
  for(uint16_t i=0; i<8; i++) {
    a--;
    stripV.setPixelColor(i, c);
    stripH.setPixelColor(a, c);
    stripV.show();
    stripH.show();

    //a--;
    delay(wait);
  }
}

void colorWipeBakoFram(uint32_t c, uint8_t wait) {
  int a = 8;
  for(uint16_t i=0; i<8; i++) {
    a--;
    stripV.setPixelColor(a, c);
    stripH.setPixelColor(i, c);
    stripV.show();
    stripH.show();

    //a--;
    delay(wait);
  }
}

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

  for(j=0; j<256; j++) {
    for(i=0; i<8; i++) {
      stripV.setPixelColor(i, Wheel((i+j) & 255));
      stripH.setPixelColor(i, Wheel((i+j) & 255));
    }
    stripV.show();
    stripH.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<8; i++) {
      stripV.setPixelColor(i, Wheel(((i * 256 / 8) + j) & 255));
      stripH.setPixelColor(i, Wheel(((i * 256 / 8) + j) & 255));
    }
    stripV.show();
    stripH.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 (uint16_t i=0; i < 8; i=i+3) {
        stripV.setPixelColor(i+q, c);    //turn every third pixel on
        stripH.setPixelColor(i+q, c);
      }
      stripV.show();
      stripH.show();

      delay(wait);
 
      for (uint16_t i=0; i < 8; i=i+3) {
        stripV.setPixelColor(i+q, 0);        //turn every third pixel off
        stripH.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 (uint16_t i=0; i < 8; i=i+3) {
        stripV.setPixelColor(i+q, Wheel( (i+j) % 255));    //turn every third pixel on
        stripH.setPixelColor(i+q, Wheel( (i+j) % 255));    //turn every third pixel on
      }
      stripV.show();
      stripH.show();

      delay(wait);

      for (uint16_t i=0; i < 8; i=i+3) {
        stripV.setPixelColor(i+q, 0);        //turn every third pixel off
        stripH.setPixelColor(i+q, 0);
      }
    }
  }
}

// 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 stripV.Color(255 - WheelPos * 3, 0, WheelPos * 3);
  }
  if(WheelPos < 170) {
    WheelPos -= 85;
    return stripV.Color(0, WheelPos * 3, 255 - WheelPos * 3);
  }
  WheelPos -= 170;
  return stripV.Color(WheelPos * 3, 255 - WheelPos * 3, 0);
}

hi,

I am not an expert on at tiny 45, but it appears there may be special considerations when using pin 1 on an at tiny 45.

Which third party board package are you using to add support for the ATTiny45?

I do not off the top of my head see the problem there... Does it work on the ATTiny85? I would try that first, as it may just be that you're running out of ram.

@Qdeathstar - he is referring to the Arduino pin numbers, these are not the same as the Arduino pin numbers. No special measures are needed for using Arduino pin 1 on an attiny x5 series.