Arduino Playground is read-only starting December 31st, 2018. For more info please look at this Forum Post

IR Lib

What is it?

This is an interrupt driven SIRCS protocol infra-red remote-control handset command decoder :) In other words, with a minimum of additional components and code, you can receive commands from SIRCS-compatible handsets. These include most S*ny handsets, a few third-party ones, and nearly every 'all-in-one' handset.

Where can I get it?

Here! Feel free to take, adapt, reuse, redistribute, and have fun! I've even included my electric postal address in case you would like to contact me with suggested improvements, comments or questions.

Using the library

Because it's interrupt-driven, the library makes very few demands on your program structure. It does however restrict you to using digital pin 2 or 3 for your component connection as these are the default pins which can trigger interrupts.

Just because I said interrupts it doesn't mean that the library's not simple to use. You just initialise, then query a buffer to see if commands have been received. There's no blocking delay, and as the the codes are buffered, no critical timing issues to worry about.

A full example sketch is included in the zip.

You can either install this code as a library in the accepted fashion, or simply include the cpp & h file in your sketch directory. Don't forget to #include <IR.h>

Adapting the library

I've kept the code small and simple to aid integration into your environment. It's heavily commented to allow more demanding users to modify it easily. I think it's more important to write simple clear code and let users modify it to their needs than to write bloated, do-everything monstrosities that always seem to fail to satisfy anyone. YOMV ;)


The hardware

There are many places on the 'net that information can be found on connecting IR receivers to micro-controllers. One I recommend is here

No longer working.

 (scroll down a little way) - please don't become incandescently furious because it's not directly related to Arduino tee em! As for the choice of IR module - many will work. It's a case of doing what's easiest/cheapest for you. I salvaged mine from a dead VCR. A lot of nods toward the Vishay range seem to indicate these are a good buy.