ir remote attiny85 problem

Hi all, im triying to program a receiver with an attiny85, but when I try to enable the ir reciver everithing goes wrong, all the timers stop working, and the program freezes.
these is my code so far:

#include <IRremote.h>
#include <EEPROM.h>

int T1=0;
int T2=0;
int T3=0;
int c1=0;

unsigned long Aini_last=0;
unsigned long Aini=0x9FF;
int ad_Aini=0;
unsigned long Adet_last=0;
unsigned long Adet=0;
int ad_Adet=20;
unsigned long Bini_last=0;
unsigned long Bini=0;
int ad_Bini=0;
unsigned long Bdet_last=0;
unsigned long Bdet=0;
int ad_Bdet=20;

int RECV_PIN = 4;
IRrecv irrecv(RECV_PIN);
decode_results results;

void setup() {

pinMode(0, INPUT);    //BUTTON
digitalWrite(0, HIGH);  //internal pull-up resistor set HIGH
pinMode(1, OUTPUT); //LED(Green)-START
pinMode(2, OUTPUT); //STOP
pinMode(3, OUTPUT); //LED2(Yellow)
//pinMode(4, INPUT);  //IR-IN
digitalWrite(1, LOW);
digitalWrite(2, LOW);
digitalWrite(3, LOW);

digitalWrite(1, HIGH);
digitalWrite(3, HIGH);

delay(1000);

digitalWrite(1, LOW);
digitalWrite(3, LOW);

T1=millis();
}

void loop() {

digitalWrite(3, HIGH);

while (digitalRead(0)==0){

  T2=millis();
  T3=T2-T1;
  
  if (T3>50){
    digitalWrite(3, LOW);
  }
  
  if (T3<50){
    digitalWrite(3, HIGH);
  }
  if(T3>100){
    T1=millis();
    c1++;
  }
  if (c1>=20){
    while (digitalRead(0)==0){
    }
    SETcodes();
  }
}

c1=0;

}

void SETcodes(){

digitalWrite(3, LOW);
digitalWrite(1, HIGH);
delay(1000);

Aini_last=Aini;
Aini=0;

irrecv.enableIRIn();

while (Aini==0){

  if (irrecv.decode(&results)) {

        Aini=results.value, HEX;
   
      irrecv.resume();
    }
}

EEPROM.put(ad_Aini, Aini);

Bini_last=Bini;
Bini=0;

while (Bini==0){

  if (irrecv.decode(&results)) {

        Bini=results.value, HEX;
   
      irrecv.resume();
    }
}

EEPROM.put(ad_Bini, Bini);

if (irrecv.decode(&results)) {
    }
    
digitalWrite(3, HIGH);
digitalWrite(1, LOW);
delay(1000);


}

if I put the irrecv.enableIRIn(); in the void setup, the program stops as soon as there is a delay or millis function. I think the tiny85 has only one timer, and that could be cousing truble if the irremote library is using it, but i have no idea.

any idea of how I can stop the library and get the timer free??

PS, I speak little english, so sorry for the bad grammar and spelling :slight_smile:

the tiny85 has only one timer, and that could be cousing truble if the irremote library is using it, but i have no idea.

Well, you should KNOW how many timers you have to work with.

The IR remote library definitely needs a timer of its own. So, if you do have only one to work with, it WILL be used by the IR remote library.

pinMode(0, INPUT);    //BUTTON
digitalWrite(0, HIGH);  //internal pull-up resistor set HIGH

You have something against the INPUT_PULLUP mode?

digitalWrite(1, LOW);
digitalWrite(2, LOW);
digitalWrite(3, LOW);

digitalWrite(1, HIGH);
digitalWrite(3, HIGH);

What is the point of setting the state, and then changing it a few nanoseconds later?

        Aini=results.value, HEX;

You are abusing the comma operator.