ATtiny85 with SoftwareSerial and Adafruit Dotstar

Hey,

I’m trying to use an ATtiny85 to build an LED controller for the Adafruit Dotstar LED strips. I plan on using an IR remote to control the colour and animation of the LEDs.

So far I’ve managed to get them working separately on different ATtiny85 controllers and have had no luck getting it running off one microcontroller. See my progress on the following thread: https://forum.arduino.cc/index.php?topic=719647.msg4835892#msg4835892

My new approach is to send out the IR code over software serial from one ATtiny85 to the other. The test code that I’m using to achieve this is given.

I’m having the issue where everything seems to work unless I try to print a line to serial or read from serial in a loop. If I comment out those lines, everything works perfectly.

Anyone have any ideas what might be wrong? (The for loop at the end is just to show a rainbow animation on the LEDs)

// Serial with Dotstar LEDs TEST
// 25/12/2020

#include <SoftwareSerial.h>
#include <Adafruit_DotStar.h>
#include <avr/power.h>

#define F_CPU 8000000
#define __AVR_ATtiny85__

#define WHITE   0x808080

#define NUMPIXELS   72

#define DATAPIN     0
#define CLOCKPIN    2
#define RX          3
#define TX          4

Adafruit_DotStar strip(NUMPIXELS, DATAPIN, CLOCKPIN, DOTSTAR_BGR);
SoftwareSerial mySerial(RX, TX);

uint16_t hue = 0;
uint8_t sat = 255;
uint8_t val = 255;
uint32_t rgbcolour = WHITE;
uint32_t irCode = 0x0;

void setup() {
  pinMode(RX, INPUT);
  pinMode(TX, OUTPUT);

  mySerial.begin(9600);
//  mySerial.println("ATtiny85 Dotstar with SoftwareSerial");
  
  pinMode(CLOCKPIN, OUTPUT);
  pinMode(DATAPIN, OUTPUT);

  strip.begin();
  strip.show();

  strip.fill(strip.gamma32(WHITE));
  strip.show();
}

void loop() {
  uint8_t bits = mySerial.available();
  if (bits)  {
    irCode = 0;
    while (bits > 0)  {
      irCode = irCode << 1;
//      if (mySerial.read() == '1') irCode |= 1;
      bits--;
    }
//    mySerial.println(irCode, HEX);
  }
  
  for(uint8_t i = 1; i < NUMPIXELS; i++)  {
    strip.setPixelColor((NUMPIXELS-i), strip.getPixelColor(NUMPIXELS-i-1));
    rgbcolour = strip.gamma32(strip.ColorHSV(hue, sat, val));
    strip.setPixelColor(0, rgbcolour);
        
    hue += 910;
    if (hue == 65520)  {
      hue = 0;
    }
  }

  strip.show();
}