Attiny85 IRremote(blinkled and Serial) error

Hello,

I done all my prototyping on a Arduino IOT 33 with my min focused on that all my code is being ported to a Attiny85. My code is working as it should in the IOT33 and when i try to compile it for the Attiny85 i receive errors that extends to the libraries. The library IRremote said to be compatible with the Attiny series.

C:\Users\stefa\Documents\Arduino\libraries\IRremote\src\private/IRremoteBoardDefs.h:130:25: error: 'LED_BUILTIN' was not declared in this scope
#define BLINKLED LED_BUILTIN

and

C:\Users\stefa\Documents\Arduino\libraries\IRremote\src\irReceive.cpp:503:23: error: 'Serial' was not declared in this scope
printResultShort(&Serial);

#include <avr/io.h>
#include <avr/sleep.h>
#include <avr/interrupt.h>
#include <IRremote.h>

unsigned long ir;
const int IR_PIN = 1; //11
IRrecv irrecv(IR_PIN);
decode_results results;

int ledpin = 0;// 9
int dimval = 193;
int ranval;// = random(50, 193);
int program;

// ------ ON/SLEEP -----
unsigned long tnow;
unsigned long tlater = 0;
bool on = false;
int IRon = 2155806975;
int IRoff = 2155823295;

// ------ DELAY -----
boolean ddelay = false;
int ddt = 1000;
unsigned long told = 0;
unsigned long tnew;
int fixedC = 0;

void sleep() {

    GIMSK |= _BV(PCIE);                     // Enable Pin Change Interrupts
    PCMSK |= _BV(PCINT1);                   // Use PB1 as interrupt pin
    ADCSRA &= ~_BV(ADEN);                   // ADC off
    set_sleep_mode(SLEEP_MODE_PWR_DOWN);    // replaces above statement

    sleep_enable();                         // Sets the Sleep Enable bit in the MCUCR Register (SE BIT)
    sei();                                  // Enable interrupts
    sleep_cpu();                            // sleep

    cli();                                  // Disable interrupts
    PCMSK &= ~_BV(PCINT3);                  // Turn off PB3 as interrupt pin
    sleep_disable();                        // Clear SE bit
    ADCSRA |= _BV(ADEN);                    // ADC on

    sei();                                  // Enable interrupts
    } // sleep

ISR(PCINT0_vect) {
    // This is called when the interrupt occurs, but I don't need to do anything in it
    }


  void irr() {
  if (irrecv.decode(&results)) {
    //Serial.println(results.value);
    //irrecv.printIRResultAsCVariables(&Serial);
    if ((results.value) == IRon) {
      tnow = millis();
      on = true;
      //Serial.println("ON");
    }
    if ((results.value) == IRoff) {
      on = false;
      analogWrite(ledpin, 0);
      //Serial.println("OFF");
      //sleep
    }
    irrecv.resume();
  }
  }


int ranset() {
  ranval = random(80, 193);
}

int progSEL() { // 1=DIM, 2=FLICKER, 3=FIXED
  program = random(1, 3);
}


void dim() {
  if (ranval == dimval) {
    program = 0;
  } else if (ranval < dimval) {
    analogWrite(ledpin, dimval);
    dimval --;
  } else if (ranval > dimval) {
    analogWrite(ledpin, dimval);
    dimval ++;
  }

  if (ddelay == false) {
    told = millis();
  }
  ddelay = true;
  ddt = random(5, 15);
  Delay();

}

void flicker() {
  if ( dimval > 60) {
    dimval -= 5;
    analogWrite(ledpin, dimval);
  } else if (dimval <= 60) {
    program = 0;
    dim();
  }
  if (ddelay == false) {
    told = millis();
  }
  ddelay = true;
  ddt = random(5, 10);
  Delay();
}

void Delay() {
  tnew = millis();
  if (ddelay = true) {
    if (tnew - told > ddt) {
      ddelay = false;
    }

  } else {
    // do nothing
  }
}

void setup() {
  //Serial.begin(9600);
  irrecv.enableIRIn();
  progSEL();
  //attachInterrupt(digitalPinToInterrupt(IR_PIN), encoderISR, CHANGE);
}

void loop() {
  irr();
tlater = millis();
if(tlater - tnow < 21600000 & on == true){
  if (ddelay == false) {

    switch (program) {
      case 0:
        progSEL();
        ranval = ranset();
        //Serial.println("case 0");
        break;

      case 1:
        dim();
        //Serial.println("DIM");
        break;

      case 2:
        flicker();
        //Serial.println("FLICKER");
        break;
    }

  } else {
    Delay();
  }
} else {
  sleep();
}
}

For the attiny85 compiling and uploading, i have successfully burned bootloader and had the first prototype work without the IRremote library.

I have also tried to manually "#define BLINKLED 0", to try to override the "LEDBUILTIN", but with no success.

Any tips to overcome these errors?

error: 'Serial' was not declared in this scope
First, which Arduino core are you using for the ATTINY85 ?

What core?

I use a ATtiny85 on breadbord, internal clock 8Mhz, using USBtinyISP.
The board is gotten from this url;

[color=#333333]https://raw.githubusercontent.com/damellis/attiny/ide-1.6.x-boards-manager/package_damellis_attiny_index.json[/color]

If you use this core: GitHub - SpenceKonde/ATTinyCore: Arduino core for ATtiny 1634, 828, x313, x4, x41, x5, x61, x7 and x8 then Serial is already defined for you (see the pinout diagram).
This core is well supported by an active user here (Dr Azzy).

You could try:

#define LED_BUILTIN N // where N is you LED pin or something unused.

Ahh, thank you very much. I'll try that core.
Thanks a lot!!

And it worked like a charm! Fantastic! :slight_smile:

fesanb:
And it worked like a charm! Fantastic! :slight_smile:

You can click on this guy's karma points (it is his core development) : https://forum.arduino.cc/index.php?action=profile;u=266415