Arduino IRremote library and problems

I have been trying to use this IRremote library with arduino 0018 on Mac:

But for some reason it doesn’t seem to work. And I don’t know why. When I try to run any example (included with the library) I get this:

/Applications/arduino-0013/Arduino.app/Contents/Resources/Java/libraries/IRremote/IRremote.cpp: In member function 'void IRsend::mark(int)':

/Applications/arduino-0013/Arduino.app/Contents/Resources/Java/libraries/IRremote/IRremote.cpp:172: error: 'TCCR2A' was not declared in this scope

/Applications/arduino-0013/Arduino.app/Contents/Resources/Java/libraries/IRremote/IRremote.cpp:172: error: 'COM2B1' was not declared in this scope

/Applications/arduino-0013/Arduino.app/Contents/Resources/Java/libraries/IRremote/IRremote.cpp: In member function 'void IRsend::space(int)':

/Applications/arduino-0013/Arduino.app/Contents/Resources/Java/libraries/IRremote/IRremote.cpp:180: error: 'TCCR2A' was not declared in this scope

/Applications/arduino-0013/Arduino.app/Contents/Resources/Java/libraries/IRremote/IRremote.cpp:180: error: 'COM2B1' was not declared in this scope

/Applications/arduino-0013/Arduino.app/Contents/Resources/Java/libraries/IRremote/IRremote.cpp: In member function 'void IRsend::enableIROut(int)':

/Applications/arduino-0013/Arduino.app/Contents/Resources/Java/libraries/IRremote/IRremote.cpp:198: error: 'TIMSK2' was not declared in this scope

/Applications/arduino-0013/Arduino.app/Contents/Resources/Java/libraries/IRremote/IRremote.cpp:207: error: 'TCCR2A' was not declared in this scope

/Applications/arduino-0013/Arduino.app/Contents/Resources/Java/libraries/IRremote/IRremote.cpp:208: error: 'TCCR2B' was not declared in this scope

/Applications/arduino-0013/Arduino.app/Contents/Resources/Java/libraries/IRremote/IRremote.cpp:208: error: 'WGM22' was not declared in this scope

/Applications/arduino-0013/Arduino.app/Contents/Resources/Java/libraries/IRremote/IRremote.cpp:211: error: 'OCR2A' was not declared in this scope

/Applications/arduino-0013/Arduino.app/Contents/Resources/Java/libraries/IRremote/IRremote.cpp:212: error: 'OCR2B' was not declared in this scope

/Applications/arduino-0013/Arduino.app/Contents/Resources/Java/libraries/IRremote/IRremote.cpp: In member function 'void IRrecv::enableIRIn()':

/Applications/arduino-0013/Arduino.app/Contents/Resources/Java/libraries/IRremote/IRremote.cpp:224: error: 'TCCR2A' was not declared in this scope

/Applications/arduino-0013/Arduino.app/Contents/Resources/Java/libraries/IRremote/IRremote.cpp:229: error: 'TCCR2B' was not declared in this scope

/Applications/arduino-0013/Arduino.app/Contents/Resources/Java/libraries/IRremote/IRremote.cpp:234: error: 'TIMSK2' was not declared in this scope

This looks like some include file was not included in your sketch, or that you have not selected the correct board in the Tools + Board menu.

Post your sketch, and tell us about the board you have.

My board is duemillanove with Atmega8, I selected atmega 8, and the correct serial port. The sketch that I am using is this (came with the library):

/*
 * IRremote: IRrecvDemo - demonstrates receiving IR codes with IRrecv
 * An IR detector/demodulator must be connected to the input RECV_PIN.
 * Version 0.1 July, 2009
 * Copyright 2009 Ken Shirriff
 * http://arcfn.com
 */

#include <IRremote.h>

int RECV_PIN = 2;

IRrecv irrecv(RECV_PIN);

decode_results results;

void setup()
{
  Serial.begin(9600);
  irrecv.enableIRIn(); // Start the receiver
}

void loop() {
  if (irrecv.decode(&results)) {
    Serial.println(results.value, HEX);
    irrecv.resume(); // Receive the next value
  }
}

Strange thing is if I try to compile this sketch for Duemillanove with Atmega328 I don’t get any errors compiling - I get errors when uploading.

If your board is a Duemilanove, it has either an ATmega168 or ATmega328. If you actually selected ATmega8, that could be the cause of the problem.

-Mike

The board is duemillanove and it has Atmega8 - my athega168 died so I replaced it with atmega8.

Well, there is your problem. Replace the ATMege8 with the proper chip or learn how to program the ATMega8. It isn't nearly as easy as programming the ATMega168 or ATMega328.

Why not? I have been using Atmega8's for some time now (because I couldn't get any Atmega168 where I live) and this is the first time I had any problem with it.

EDIT: The library appears to be using some low level "functions" and isn't written for Atmega8. Also the code is too big to fit the Atmega8. Next time I am ordering from farnell I realy have to buy a few Atmega328.