How to use IRremote library with atmega8a A few days ago I tested  a circuit on a  breadboard based on a ATmega8a with 1 MHz internal oscilator. It sould turn on and off a relay based on a IR code that is received and if it matches the programmed in the EEPROM it shoud enable or disable the relay. Now I developed a PCB and soldered everything together but now it isn't working. On an Arduino Nano it is working ok.

#include &lt;IRremote.h&gt;
#include &lt;EEPROM.h&gt;

int RECV_PIN = 11;
int RELAY_PIN = 4;
int setpin = 3;
unsigned long work_at;
unsigned long adres;
unsigned long irbuffer;
IRrecv irrecv(RECV_PIN);
decode_results results;

void dump(decode_results *results) {

    if(digitalRead(setpin) == 0){
      work_at = results-&gt;value; 
      Serial.println(work_at, HEX);    
    }
    irbuffer = results-&gt;value;

}

void eeprom_writer(){
  if (irrecv.decode(&amp;results)) {
    if(digitalRead(setpin) == 0 &amp;&amp; work_at != 0){
      EEPROM.put(0, work_at); //put walue
      Serial.println(work_at, HEX);
      adres = work_at;
      Serial.println(adres, HEX);
      delay(1000); //wait
   }
  }
}
void setup()
{
  EEPROM.get(0, adres);
  pinMode(setpin, INPUT_PULLUP);
  pinMode(RELAY_PIN, OUTPUT);
  Serial.begin(9600);
  irrecv.enableIRIn(); // Start the receiver
}

int on = 0;
unsigned long last = millis();

void loop() {
  if (irrecv.decode(&amp;results)) {
    // If it's been at least 1/4 second since the last
    // IR received, toggle the relay
  //  if(&amp;results == adres){
      dump(&amp;results);
      if (millis() - last &gt; 250) {
        on = !on;
        if(on == true &amp;&amp; adres == irbuffer){
          delay(5000);
          digitalWrite(RELAY_PIN, on ? HIGH : LOW);
          dump(&amp;results); 
        }else if(on != true  &amp;&amp; adres == irbuffer){
          digitalWrite(RELAY_PIN, on ? HIGH : LOW);        
          dump(&amp;results); 
          delay(5000);
        }
      }
    //}
//    Serial.println(dump(&amp;results));
//    Serial.println(count, DEC);

    eeprom_writer();
    last = millis();      
    irrecv.resume(); // Receive the next value
  }
}
Changing the internal oscillator to 8MHz helped.