A few days ago, I demonstrated an Arduino Duemilanove circuit that would receive keypresses from a TV remote control. Well, I had so much fun with it that I made the code more advanced, and I made a new video demonstrating what I did. Watch the video, download the code, and let me know what changes you made.

After watching the video, you’ll know what to expect. The next step is to get my Arduino sketch, which is available right here:

ir_decodepde.zip

Next up, you need an IR Receiver. I use the RadioShack 38 kHz IR Receiver Module (part number 276-640). This costs $4, and it’s in almost any RadioShack I’ve ever been to (even the small ones that look like they only sell cellphones and toys). I know, I know – RadioShack has a reputation for selling shoddy parts, but whatever. I’ve only been burned once, and it’s worth it for the instant gratification of getting what I need without waiting for shipping.

Next, you need a solderless breadboard. I recommend the Arduino Protoshield, but since I haven’t assembled mine, I am using my breadboard (RS part number 276-169). I’m not sure if this is still for sale, so please let me know if you have any luck getting one.

Finally, you’ll need some small wires, some LEDs, and some resistors. Get two LEDs (the cheapest you can find), two 10K-ohm resistors, and a 220 ohm resistor.

Oh, and you’ll need a remote control. I’m using the Sony RMT-V202. This is up to you, and I can’t promise that my code will work unmodified with any other remote. However, I can tell you that my code is an excellent starting point, since it will give you all of the IR timings that you need to understand what your remote is “saying.” Remember how the video had a “debug mode” for looking at the timing of the IR pulses? This is your key to adapting the code to any remote, whatsoever.

If you need help understanding how to use a breadboard with the Arduino, I recommend watching the following video. The video demonstrates, in somewhat excruciating detail, how to build a totally different project with the Arduino. It’s kindof fun to watch, anyway…


How-to Tuesday: Fun with the Arduino Starter Kit from make magazine on Vimeo.

So, have fun! Also, I want to hear about your experiences using my code and video to play with your Arduino.

  • Pingback: rtfa.net » Arduino infra-red (IR) remote control

  • franklin

    LIke your project, nice video too!

    I was thinking about taking your approach on a project of mine, but I am having difficulty understanding exactly how you wired the components. Would you provide some kind of diagram with the wiring (even if its really simple)? Thanks.

  • farkinga

    Thanks! Let me see what I can come up with.

  • salsa

    Wow, this is fantastic– thanks, farkinga!! Good thing I have some old Sony remotes– my TiVo and Denon remotes produce only errors– I got codes for every button! Nice clean code– I am munging it with excellent results…:) BTW are you sure you're using 10K resistors for the LEDs and not 100s? With 10K, you wouldn't get much (if any) light.

    Franklin, the wiring of the IR receiver is very simple– I'm using a scrounged HS0038A2:
    http://www.alldatasheet.com/datasheet-pdf/pdf/2
    and it works the same as the RS one, I think– pin 1 to gnd, pin 2 to vcc, and pin 3 to Arduino pin 7 through a 220 ohm resistor.

  • salsa

    Wow, this is fantastic– thanks, farkinga!! Good thing I have some old Sony remotes– my TiVo and Denon remotes produce only errors– I got codes for every button! Nice clean code– I am munging it with excellent results…:) BTW are you sure you're using 10K resistors for the LEDs and not 100s? With 10K, you wouldn't get much (if any) light.

    Franklin, the wiring of the IR receiver is very simple– I'm using a scrounged HS0038A2:
    http://www.alldatasheet.com/datasheet-pdf/pdf/2
    and it works the same as the RS one, I think– pin 1 to gnd, pin 2 to vcc, and pin 3 to Arduino pin 7 through a 220 ohm resistor.

  • austone

    when i press a button nothing writes to my serial montior, even when i have my debug on and off what is the problem?

  • austone

    nvm i found out the problem, most of these remotes dont work youll need to get like an universal remote and stuff

  • Pingback: Occasional Comment » Blog Archive » Arduino Mania Strikes Elkton

  • jeanot13

    I am trying to do the same project, but with a Tsop 1730 (IR receiver)…. i have adapted the circuit, but impossible to create a contact with the remote! The Tsop detect frequence at arround 30kHz do you think this could be the problem?
    Maybe there is something to change in the program…. but i cannot find what!!!

  • indoctrin8ed

    Good code basis, but my Sony remote(s) do not use these codes. I added “Serial.println(key);” at the beginning of do_response() to see what codes I'm seeing. I get these:
    Power: 149
    Vol up: 146
    Vol dn: 147
    Display: 186
    Channel +: 3377
    Channel -: 3376

    etc.

  • calibishie

    I am a bit new to the arduino, I'm trying to understand the reason for the 220 ohms resistor. Could someone help me?

  • Chile

    Hi, this is very clean and well done code. It worked for me immediately with a sony remote. It works 24*7 on a current project. Problem is, I started to find random activation with no remote input!
    I still don't know why. Behavior is just like a signal was received so the relay gets activated.

    1) This happens randomly, every several hours, at different times.
    2) I made sure that no neighbour or any IR intrusion came in through the window by monitoring the IR receiver: I got random relay activation without any record of IR activity.
    3) I regrounded the whole circuit to avoid noise at a circuit level.

    Is there any chance that the code goes in a case statement but with no IR signal present? I know it sounds silly, but maybe you have experienced something similar.

  • andre

    Possibly ambient-light flickering has erroneously triggered the sensor? I am just about to wire this one up but I know natural and artificial light sources contain energy in the IR region of the spectrum.

    What does your data look like? Can you verify it's an electronic source? How is the power at your location?

    Just throwing out a couple of ideas:

    1. If it is some sort of ambient light interference you could try adding addition IR filtering- I have heard that after a roll of film has been developed, the ends of the rolls that did not contain photography can act as an IR filter. I have not tried this trick and you may sacrifice IR range if this “film-filter” does not cleanly pass the IR band of light.

    2. You may try constricting the field of vision of the receiver. An interesting experiment might be to shield the receiver from above with an opaque material to see if it is the lights.

    3. Maybe try covering the whole IR receiver for a day and if you still get the errors you could be pretty certain that the bug was in the circuit or code and not necessarily in the receiver.

    Best of luck-

    Cheers,

    andre

  • Chile

    Thanks for your advice Andre. I followed what you suggested and it appears that you were right. Since the IR sensor is deep purple itself I thought the IR filter was present already but no. I added an old negative film, narrowed the field and all.

    I never thought daylight could cause such interference in a software that reads binary sequences!

    It's been three weeks with no issues so far. Thanks again.

  • http://www.easyrecovery.co.uk data recovery

    I liked this post.Good job.

  • Marcusramse1

    Just pumps outs Errors for me… How can I fix this. I know its correctly wired.

  • farkinga

    your remote probably uses a different encoding than the sony remote I used. When I wrote the code, I didn’t realize there are several ways to indicate ones and zeros… so it may not be a matter of “a short pulse is a zero, a long pulse is a one.”

    I recommend looking up your remote by its serial number, and add “encoding” or “pulse width” or “modulation” to the query. There are many strategies that engineers employ these days…

    And please update RTFA if you have success. Thanks!

  • Amir Mousavizadegan

    Get job… I have done similar work for controlling channel master remoter box with the Arduino, howevere, I have a new project and I would like to bypass IR and feed the Arduino output signal directly to channel master IR output Pin in box, is this possible?….
    thx
    Amir

  • Pingback: Arduino TV (IR) Remote Controlled Car | Minds Departure