Really simple Arduino IR receiver

Arduino with IR remote receiver
I use a Mac Mini as a media center computer. While I generally like Front Row, and have a few custom (unsupported) plugins, sometimes you really just want something one button away. I’m already using a universal remote, but the Mini’s built-in IR receiver can only detect the signals for the 6 buttons on the Apple remote.

As a quick-and-dirty solution, I wrote this sketch for the Arduino, using a generic IR remote receiver. When reset, the Arduino starts listening for an IR remote command. It remembers the timing of the pulses, then listens for a similar set of pulses and signals over the serial port. I wrote a few lines of Python to listen to the serial port and do something interesting.

Now I can eject a DVD without messing with any menus. I’ll probably need a more complete solution some day, but for now, I’m set.

Download IRMon

7 thoughts on “Really simple Arduino IR receiver”

  1. Hey, thanks for sharing this, you’ve saved me tons of research and have jump started my little project.

    Unfortunately, you’ve saved me tons of research.

    The ir I’m trying to read is binary at 36k, and your code reads 38k, which worked fine for a standard remote. I’ve been tinkering with the code and I’m wondering what you are doing to make it 38k?

    Regardless, thanks again!

  2. Jesse –

    The code itself doesn’t pay attention to the rate of the IR signal. The IR receiver I used is designed for 38 KHz, and demodulates the signal. To get it to work with a different frequency, just buy a different receiver. 36 is still pretty common. A quick search with your favorite search engine will turn up a bunch of good articles on how the modulation works.

    My code also doesn’t try to decode any particular protocol. It just records the timing of the demodulated signal, so it should work with any remote, given you have an appropriate receiver.

  3. Lucas – I couldn’t get my Arduino IR transmitter to work until I tried your implementation of modulate(). So now I can make it turn on/off my Sony DVD player with discrete codes. Many thx for that. But now I’m stymied trying to teach the command to my learning remote (URC RF-20). The remote is supposed to say GOOD or FAILD during the learning process, but it just sits there saying READY like it’s not receiving anything. I tried it at different distances. I tried sending it the code once and tried sending it repeatedly. Maybe the signal produced by the Arduino is just not strong enough for the remote? It has only about a 3ft range on the DVD player.

  4. Glenn — I assume you’re really talking about my other IR post. I’m glad you found it useful.

    Some troubleshooting thoughts:
    You can use a webcam or a digital camera to see how bright the IR LED is.
    I had luck with sending the same code continuously for programming, but you could try adding a short delay.
    For range, according to this, pin 13 has a 1k resistor attached to it. You could try moving it to another pin and using a smaller resistor. With the Arduino running at 5V, and a 1.28V 20mA IR LED, you’d want a 200 ohm resistor ( (5-1.28)/0.020 = 186 ohm ). That would make the LED brighter. Be sure not to exceed the LED’s current rating, or go above the 40 mA that the Arduino can source.
    LEDs can be pretty directional, make sure it’s pointed at your target. I had the best results programming my remote when I pointed the LED right at front of the remote, with about a 6 inch gap.

  5. Oh yes, sorry, I’m responding to your other post. I was looking at IRmon, too. That’s clever how you used the speed of the program as the yardstick to get a signature of a code.

    Hmmm. I wonder if this is my problem: I’m using the kind of IR LED that comes attached to a 7′ wire and is used with an IR blaster. Maybe this kind of LED is designed to be weaker than normal ones so that, when it is glued on the glass less than an inch from the IR receiver, it doesn’t overwhelm it.

    Just after mailing you, I went straight to trying the led on another pin with no resistor:) I was hoping that the modulation would save it, but maybe it has a resistor built-in behind the plug, and that saved it? In any case, it didn’t burn out, but it still didn’t program either. These IR LEDs have a red LED “tell-tale” and maybe it was brighter with no resistor, but not as bright as I thought it would be.

    Another possibility just occurred to me. Maybe the adhesive, that the IR light has to shine through, is dirty. The thing was sitting in a closet for 3 years, and when I found it yesterday, the peel-off paper was missing and the adhesive was just barely tacky.

    Thanks for your thoughts.

  6. Yeah, I have one of IR blaster wire things with a headphone jack on the end. I haven’t done much with it yet, but I’ve read that they tend to be pretty dim. On mine, I’ve found that the LED is actually mounted so that it points out the side, not through the adhesive. You can use the digital camera trick to figure out where it’s brightest.

    Most electronics will survive outside of what they’re designed for.. the problem is you never know how long. :) Current-limiting resistors are your friend.

    Make sure when you’re programming your remote you’ve set the Arduino code to send out the code repeatedly. You can try programming the remote with something else, too, to isolate where the problem is. Sunlight and florescent lights can cause problems with IR, too.

  7. Success at last.

    Today’s escapades:
    I tried to get my universal learning remote to learn from an old remote I wasn’t using anymore and had success with it. So I popped open the old remote and de-soldered the IR LED and put it on the Arduino circuit in place of the blaster wire LED. I put a 230 Ohm resister across pin 2 and used the 0x04 mask on PORTD in modulate(). When I ran the sketch and viewed the light through a digital camera, I was disappointed at how dim it was. The universal remote would not learn from it, either. I soldered the LED back onto its original remote and looked at the brightness through the camera. Much brighter! De-soldered again and put back on Arduino set-up. This time I tried to learn from it by orienting the universal remote to point at the tip of the LED. It took a few seconds, but it eventually said GOOD. A short-lived breakthrough, as when when I tried my remote on the DVD player, it didn’t work. So GOOD isn’t really good all the time. Then I changed out the 230 Ohm resistor for a 12 Ohm resistor and crossed my fingers. It was much brighter, the remote learned it faster, and most important of all, it worked on my DVD.

    I should probably try to put a few 10 Ohm resistors in series before programming my next key.

Leave a Reply

Your email address will not be published. Required fields are marked *