Control Arduino with Universal Remote

Maybe a syntax error of some kind? Did you cut and paste the code exactly as is, or type it in yourself? If the latter, post your code and maybe I can spot the problem. By the way, I got this working perfectly, basically by making sure the servo was stopped anytime I was reading the receiver. I think there was some interference going on.

hi, sorry i didnt mean to confuse but i copied and pasted the original code posted by jmknapp and for some reason recieved those errors. i copied and pasted exactly and cannot get it to work.
any ideas?

The code was written for version 0011 of the IDE. You are running version 0012.

There are a few fixes floating around on the forum. Check the last post here:
http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1221741304/52#52

But also do some searching around.

ladyada has a version of servotimer1 that works with 0012 here: http://www.ladyada.net/media/mshield/ServoTimer1-fixed.zip

No that code worked fine for me, make sure you've got the NECIR library installed.

I have the NECIRrcv.h library added to the Arduino sw but still get compiling errors when compiling the small program that is listed above:

In file included from C:\Program Files\arduino-0012\hardware\cores\arduino/WProgram.h:4,

c:/program files/arduino-0012/hardware/tools/avr/lib/gcc/../../avr/include/stdlib.h:80: error: expected unqualified-id before 'int'

c:/program files/arduino-0012/hardware/tools/avr/lib/gcc/../../avr/include/stdlib.h:80: error: expected `)' before 'int'

......

c:/program files/arduino-0012/hardware/tools/avr/lib/gcc/../../avr/include/stdlib.h:176: error: '__compar_fn_t' has not been declared

In file included from C:\Program Files\arduino-0012\hardware\cores\arduino/WProgram.h:6,

Do I need some other library? WProgram?

Please help... I am totally new and "desperately" need a working NEC IR receiving sketch.

Thanx...

did you check out the what trialex posted above?

I think I can take two things from this post:

  1. Include #undef int somewhere

    • Moved insertion of #include <WProgram.h> to after any comments and #include statements in the main sketch file. This means that an #include <stdlib.h> now works.

If one of these or both are supposed to "do the job" where do I have to change code then? In "NECIRrcv.h" or in the "main sketch calling "NECIRrcv.h"?

Peter.

Hi, I am a noob at Arduino en English... :stuck_out_tongue:

And I have a problem, I use a IR Photodiode for this library, does that work? And do you must connect the Photodiode to a analog pin or a digital?

The IR signal from a remote control has a carrier frequency, usually around 38kHz or 40kHz. This helps filter out noise because the system can ignore any signal that's not at the carrier frequency.

The IR modules discussed in this thread strip out the carrier and just output the signal. If you use a straight photodiode connected to an Arduino pin, the pin will see the carrier frequency, and you will have to deal with that signal.

You would connect it to a digital input, but connecting it isn't completely straightforward.

Hey Lighty,
To be able to receive and decode commands from remote controls you would need an IR receiver, like this one:

This is an IC that does much more than a photodiode.
Signals from this IR receiver is digital, so you connect it to a digital input.
Read this:
http://www.arduino.cc/playground/Code/InfraredReceivers
or follow this thread for another solution:
http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1176098434

Ah this is really cool!

Where did this code go?

does anyone still have this library? can you send it to me?

Here are some mirrors where you can download the necirrcv file.

http://www.easy-upload.nl/index.php/file/164a43b8100a5b3
http://lemio.nl/files/necirrcv.zip

Modernators, please add these to the begin post.

Had same compiler problems as Jacobson and others.

Finally got this working on Duemilanove with ATMEGA328 and using Arduino 16.

Secret was to add: #include <WProgram.h> to main sketch like this:

// look for IR codes and print them as they are received

#include <WProgram.h>
#include <NECIRrcv.h>
#define IRPIN 4    // pin that IR detector is connected to

NECIRrcv ir(IRPIN) ;

void setup()
{
  Serial.begin(9600) ;
  Serial.println("NEC IR code reception") ;
  ir.begin() ;
}

void loop()
{
  unsigned long ircode ;
  
  while (ir.available()) {
    ircode = ir.read() ;
    Serial.print("got code: 0x") ;
    Serial.println(ircode,HEX) ;
  }
}

Works like a charm!

Regards to all,
Mark
Ottawa, Canada.

If you are going to be using this library in more than one sketch, instead of adding #include <WProgram.h> to each sketch that uses the library, you can add it as the first line in the NECIRrcv.h file.

On Ubuntu it gives this error:

/usr/lib/gcc/avr/4.3.5/../../../avr/include/stdlib.h:111: fout: expected unqualified-id before 'int'

/usr/lib/gcc/avr/4.3.5/../../../avr/include/stdlib.h:111: fout: expected `)' before 'int'

/usr/lib/gcc/avr/4.3.5/../../../avr/include/stdlib.h:111: fout: expected `)' before 'int'

The problem likely isn't with your board, it isn't likely be an ubuntu related issue.
You made a syntax error in your code.

Regardless of the problem, we can only geuss at what might be wrong.. thus we can't give answers or solutions, untill we see the full sketch (preferably posted in between [ code]putyourcodehere[ /code] tags)