Error compiling ATtiny85 trinket with IDE

Hello,

First time using an ATtiny85 and I'm not sure if this is the right place to ask. I've installed the relevant drivers and libraries for Digispark, and a demo code does compile and upload to the board.

I wrote my code and tested on an UNO and everything works as intended. However, I get an error when compiling for Digispark. The error message seems to suggest it's because of FastLED, but anything I can find online suggests that it should work.

Blockquote In file included from D:\Users\Steve\Documents\Arduino\libraries\FastLED/FastLED.h:65:0,
from D:\Users\Steve\Documents\Arduino\LED_nightlight\LED_nightlight_attiny\LED_nightlight_attiny.ino:1:
D:\Users\Steve\Documents\Arduino\libraries\FastLED/fastspi.h: At global scope:
D:\Users\Steve\Documents\Arduino\libraries\FastLED/fastspi.h:130:23: note: #pragma message: No hardware SPI pins defined. All SPI access will default to bitbanged output
pragma message "No hardware SPI pins defined. All SPI access will default to bitbanged output"

This might be a very dumb question, but I was under the impression that I can use the same arduino coding for the ATtiny as long as I'm using the arduino ide. But I cannot for the life of me find the answer to this.

I'm at a loss at what I need to do. Any help would be much appreciated.

Thank you.

#include <FastLED.h>


#define LED_PIN     5
#define NUM_LEDS    48
//#define BRIGHTNESS 10
#define LED_TYPE    WS2812B
CRGB leds[NUM_LEDS];

uint8_t paletteIndex = 0;

int button = 1;
int dimmerButton = 3; 

//int color;
//int readColor;

int brightness;

//main button
int inputDelay = 400;
long int previousInput; 
//int buttonInterval = 1000; 
int buttonCounter = 0;
bool buttonState = 1;
bool lastButtonState = 1;
bool powerState = 0;

//dimmer button 
int dimmerButtonCounter = 0;
bool dimmerButtonState = 1;
bool lastDimmerButtonState = 1;

//timing
unsigned long startTime = 0;
long int timer[] = {5000, 10000, 15000};

long int timeOne = 5000;
long int timeTwo = 10000;
long int timeThree = 15000;

void setup() {
  //delay( 3000 ); // power-up safety delay
  //Serial.begin(9600);

  pinMode(button, INPUT_PULLUP);
  pinMode(dimmerButton, INPUT_PULLUP);
  
  FastLED.addLeds<LED_TYPE, LED_PIN,GRB>(leds, NUM_LEDS);
  FastLED.clear();
  FastLED.show();
 

}

void loop() {

    dimmerButtonState = digitalRead(dimmerButton);
    if(dimmerButtonState != lastDimmerButtonState)
    {
      if(dimmerButtonState == 0)
      {
      dimmerButtonCounter++;
      }
      delay(50);
    }
    lastDimmerButtonState = dimmerButtonState;

  if(dimmerButtonCounter == 0)
  {
    brightness = 30;
  }
  if(dimmerButtonCounter == 1)
  {
    brightness = 60;
  }
  if(dimmerButtonCounter == 2)
  {
    brightness = 90;
  }
  if(dimmerButtonCounter == 3)
  {
    dimmerButtonCounter = 0;
  }
  
  
  
  buttonState = digitalRead(button); 
    if (buttonState != lastButtonState)
    {
      if (buttonState == 0)
      {
      buttonCounter++;
      
      switch(buttonCounter)
  {
    case 0: 
      //Serial.println("0");
      FastLED.clear();
      FastLED.show();
      powerState = 0;
      break;
    case 1: 
      //Serial.println("1");
      startTime = millis(); 
      powerState = 1;
      break;
    case 2: 
      //Serial.println("2");
      startTime = millis();
      powerState = 1;
      break;
    case 3: 
     // Serial.println("3");
      startTime = millis();
      powerState = 1;
      break;
    case 4: 
      //Serial.println("4");
      powerState = 1;
      break;
   }
      }
      delay(50); 
    }
    lastButtonState = buttonState;

  
  if(buttonCounter != 0)
  {
    brightnessSet();   
    setColor();
  }
  
  if(buttonCounter > 4)
  {
    buttonCounter = 0;
   // Serial.println("0");
    FastLED.clear();
    FastLED.show();
    powerState = 0; 
  }
  
  if(powerState && (millis() - startTime > timer[buttonCounter - 1]) && buttonCounter != 4)
  {
    buttonCounter = 0;
    //Serial.println("0");
    FastLED.clear();
    FastLED.show();
    powerState = 0; 
  }

  
  

//  Serial.println(average);
}

void setColor() {
  for(int i = 0; i < NUM_LEDS ; i++)
      {
          leds[i] = CRGB(255,85,0);
          FastLED.show();
        }
        
}

void brightnessSet(){
  
  FastLED.setBrightness(  brightness );
  FastLED.show();
}```

Hi.
I think you have to tell the IDE that the target board is the ATtiny85. Did you do that?

My memory is dim on this, but do you need to install the correct "core"?

Are you using the bare chip or the Digispark board?

I am using the board from digispark. I have also set the board to the digispark default 16.5mhz as that is what the tutorials say.

I did successfully upload a demo attiny code with the same setting from the IDE, so my assumption is that there might be something wrong with the compatibility of my code. :confused:

where is the error? the message you posted is not it

Hi
So it's already been an error:

#include <FastLED.h>

void setup() {
}

void loop() {
}

I don't know if the library supports Attinyxx.

ref: GitHub - FastLED/FastLED: The FastLED library for colored LED animation on Arduino. Please direct questions/requests for help to the FastLED Reddit community: http://fastled.io/r We'd like to use github "issues" just for tracking library bugs / enhancements.

supported platforms
Right now the library is supported on a variety of arduino compatible platforms. If it's ARM or AVR and uses the arduino software (or a modified version of it to build) then it is likely supported. Note that we have a long list of upcoming platforms to support, so if you don't see what you're looking for here, ask, it may be on the roadmap (or may already be supported). NB at the moment we are only supporting the stock compilers that ship with the arduino software. Support for upgraded compilers, as well as using AVR studio and skipping the arduino entirely, should be coming in a near future release.

Arduino & compatibles - straight up arduino devices, uno, duo, leonardo, mega, nano, etc...
Arduino Yun
Adafruit Trinket & Gemma - Trinket Pro may be supported, but haven't tested to confirm yet
Teensy 2, Teensy++ 2, Teensy 3.0, Teensy 3.1/3.2, Teensy LC, Teensy 3.5, Teensy 3.6, and Teensy 4.0 - arduino compatible from pjrc.com with some extra goodies (note the teensy LC, 3.2, 3.5, 3.6, 4.0 are ARM, not AVR!)
Arduino Due and the digistump DigiX
RFduino
sparkcore
Arduino Zero
ESP8266 using the arduino board definitions from http://arduino.esp8266.com/stable/package_esp8266com_index.json - please be sure to also read ESP8266 notes · FastLED/FastLED Wiki · GitHub for information specific to the 8266.
The wino board - http://wino-board.com
ESP32 based boards
What types of platforms are we thinking about supporting in the future? Here's a short list: ChipKit32, Maple, Beagleboard

Look this site:

https://www.ka4designs.com/fastled-attiny85/

1 Like

Alas, that is largely not true. By the time you get to the sort of very libraries for very timing-dependent external devices (like neopixels), the code tends to become very processor-specific WRT instruction choice, timing decisions, and internal peripheral use.
Some libraries are very carefully written to support many different varieties of Arduino, but many were written with some particular board in mind, without paying any attention to other available boards.

However, the message reported in the original post:

pragma message "No hardware SPI pins defined. All SPI access will default to bitbanged output"
is not an error, or even a warning. It's just a message, and it means exactly what it says. The "FastLED" stuff will be less fast, because it doesn't have hardware SPI. AFAICT, the library does support the ATtiny85, and your sketch might (should?) work anyway... did you actually try uploading and running it?

if it doesn't work, you could try the standard adafruit neopixel library instead... I know I've had that work on a tiny85... Here's a "programmable any-color LED" (neopixel piggybacked on an ATtiny chip...

1 Like

Thank you. I will look into using the adafruit library instead. Didn't realize compatibility between boards and libraries was something that needed to be considered.

Just wanted to let you know that the Adafruit neopixel library worked. Thank you!

how much memory you have left after using it?

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.