Instructables

How to Use IR Remotes with Arduino (Current and Updated!!!)

Picture of How to Use IR Remotes with Arduino (Current and Updated!!!)

I'm tired of these complicated tutorials on how to use certain things. I like simple, easy to understand, step by step instructions. My biggest problem was with IR and POV*. I've finally mastered how to control my project with any TV remote in a few minutes. In this i'ble I'm going to show you simple, step by step instructions on how to control just about anything with your IR remote.

By the way this tutorial is new and updated and works! Last update [ 8/1/13 ]


Now I've never tested this process on a windows but I know
that it works on a mac. It should be the same for windows, just delete any mac content in the zip.

 
Remove these adsRemove these ads by Signing Up

Step 1: Ingredients:

Electronics:
  • Arduino
  • Any IR remote
  • IR receiver
  • Breadboard
  • Jumper Cables
  • LED

And here is the Make-To-Learn contest questions! - don't forget to vote!

What did you make?
Well I didn't make anything specific in this instructable but it is more of a guide to how to make your other projects 'wireless'.
My projects works by taking TV remotes and other remotes, converting their signals to numbers, and using them.
How did you make it?
I've been working on trying to use IR remotes. All the tutorials I found didn't really put the all the bits and pieces together for me. My main goal was to make an easy tutorial for others to follow.
Where did you make it?
At my computer. I am now able to control my robots and other stuff, like lights and lighting. For instance, I could make it so that whenever I hit the play button on my DVD player remote, the lights in the room dim, or go out.
What did you learn?
My biggest challenge was finding a IR decoder that worked, and then finding installing the proper library.

Step 2: Downloads

Here is the link to all the downloads in this instructable.
(Sorry for some odd reason the link won't work so just copy and paste it in your browser)

http://www.mediafire.com/download/cv0r5191fvtq0y2/IR_I'ble_Package.zip

1-40 of 166Next »
nreahal made it!9 months ago

Sir,

I am very thankful for your help by these tutorials. I have just received my Arduino NANO in the afternoon and at 9 i have completed my very first Arduino project "led control using ir remote", thanks to your amazing tutorial. In the following images i have been trying to show that when i press volume up it will switch ' on ' the right LED and when i press the volume down button it will switch ' off ' the LED and same has been done to the right one using program up and down of the ir remote.
Thank you once again,
regards

Nishant(INDIA)

:)

20140524_213404.jpg20140524_213431.jpg20140524_213441.jpg20140524_213913.jpg20140524_213922.jpg
FoamboardRC (author)  nreahal5 months ago

Sweet man! Good job! Keep up the good work!

I have made my mom's room room automated. Now its time for the other room you are awesome ;) :) :). Blessings from my mom too. you are awesome :)

FoamboardRC (author)  nreahal5 months ago

Wow thanks! That is soo cool! I keep on telling myself that I should hook up my light and my fan and outlets to IR, but I'm too lazy to get around to it! Good luck!

UrbanErosion made it!4 days ago

Thanks for the Instructable! I want to turn my amp on and off when my Arduino senses signal from my Sonos. Needed the codes from my remote as I couldn't find them elsewhere.

IMG_20150224_102731.jpg
Can you help me with the errors i keep getting Like tkd2 was not declared?

rename files downloaded IRremote.h and IRremoteInt.h with another name, if you dont replace file has conflict with default libraries in Arduino (Arduino/libraries/RobotIRremote/IRremote.h

thats works for me

Sorry now its say stuff like no classname, im getting really close to giving up.
FoamboardRC (author)  chickenwing220 days ago

Post it on the Arduino forum. . . I can't help.

This is just superb! Great tutorial. It served as my very first mini project. Now this can be taken to a greater level. Kudos to you!

Thanks! Glad I could help!

friend'm new here on your blog, how to light the lamp of the fan and the fan, using his remote control and the IR for Arduino.

Example = pick up the remote fan, tighten to the IR, record and then use IR light to light and turn on the fan using the notebook and also via bluetooth.

thank you

FoamboardRC (author)  alexlribeiro16 days ago
That's for a future instructble. Stay subscribed :D
vinay074522 days ago

I have install the library but the examples in that library show "error compling" when uploaded.

FoamboardRC (author)  vinay074522 days ago
That's all it says? What's the specific error?

IRtest.cpp.o: In function `__static_initialization_and_destruction_0':

C:\Program Files (x86)\Arduino/IRtest.ino:59: undefined reference to `IRrecv::IRrecv(int)'

IRtest.cpp.o: In function `IRsendDummy::useDummyBuf()':

C:\Program Files (x86)\Arduino/IRtest.ino:87: undefined reference to `irparams'

C:\Program Files (x86)\Arduino/IRtest.ino:88: undefined reference to `irparams'

C:\Program Files (x86)\Arduino/IRtest.ino:93: undefined reference to `irparams'

C:\Program Files (x86)\Arduino/IRtest.ino:93: undefined reference to `irparams'

C:\Program Files (x86)\Arduino/IRtest.ino:93: undefined reference to `irparams'

IRtest.cpp.o:C:\Program Files (x86)\Arduino/IRtest.ino:93: more undefined references to `irparams' follow

IRtest.cpp.o: In function `verify(unsigned long, int, int)':

C:\Program Files (x86)\Arduino/IRtest.ino:123: undefined reference to `IRrecv::decode(decode_results*)'

IRtest.cpp.o: In function `testRC6(unsigned long, int)':

C:\Program Files (x86)\Arduino/IRtest.ino:152: undefined reference to `IRsend::sendRC6(unsigned long, int)'

IRtest.cpp.o: In function `testRC5(unsigned long, int)':

C:\Program Files (x86)\Arduino/IRtest.ino:147: undefined reference to `IRsend::sendRC5(unsigned long, int)'

IRtest.cpp.o: In function `testSony(unsigned long, int)':

C:\Program Files (x86)\Arduino/IRtest.ino:142: undefined reference to `IRsend::sendSony(unsigned long, int)'

IRtest.cpp.o: In function `testNEC(unsigned long, int)':

C:\Program Files (x86)\Arduino/IRtest.ino:137: undefined reference to `IRsend::sendNEC(unsigned long, int)'

hey I found a solution for this.

go to Documents\Arduino\libraries\IRremote and right click on "IRremoteInt.h" and select edit. then it open change "#include <WProgram.h>" to #include <Arduino.h>. Worked for me. I hope it'll work for you.

FoamboardRC (author)  vinay074520 days ago

Ok so it's not recognizing the library. First of all make sure that you've included the library in your sketch, and then make sure you have the library installed in the correct place. If you changed the name of library it wouldn't work. Otherwise try redownloading it, or try it directly from ken shirrif's page,

https://github.com/shirriff/Arduino-IRremote

If it still doesn't work post on the Arduino Forums.

Can you help me with the errors i keep getting Like tkd2 was not declared?
FoamboardRC (author)  chickenwing21 month ago
Post it on the Arduino forum. . . I can't help.
Araonp1 month ago

do you know how to use codes in hex format?

FoamboardRC (author)  Araonp1 month ago
No.

thx anyway

Hi, great tutorial, got the IR remote working straight away, thanks. A quick question, if I want to manage multiple operations with the remote but leave them on while doing another operation how would I go about it. What I want to do is control some LEDs on a model, switch engines on half brightness, then full, also fire guns and start and stop flashing. Hope that makes sense! All the tutorials appear to be for single action remote. Thanks.

FoamboardRC (author)  warren.monks.31 month ago

Look at the switch case example.

naminshah2 months ago

whenever i try to compile the decoder sketch it gives me an error compiling message with n reason why ..,... could u provide me with some insight

FoamboardRC (author)  naminshah2 months ago

There's always a reason for the error. What board are you trying to upload it to?

Atom 62 months ago

Hi,

I really appreciate you making this instructable. I'am using your idea but using the remote to control a servo instead of an LED.

Thanks,

Atom 6

FoamboardRC (author)  Atom 62 months ago

Thanks! Coolio! GL!

Hello FoamboardRC you should know that I am trying to build a steampunk robot. I really want it to be rc and here is my code which I am trying to get to work.

if (IRRX.decode(&results) == 2331063592)

{

Serial.println("Pause");

}

Basically it means or what I think it should mean is that 2331063592 is an ir signal from my TV remote. Then I want it to say pause in the Serial Monitor. Also in case you are wondering IRRX is short for what you wrote as IRrecv. Thanks!!!

FoamboardRC (author)  nschreiber08132 months ago

You never asked a question. What do you want me to do?

Whoops sorry I forgot to look at your LED 2 code. Never mind I got it working. Thanks anyways...

SteveR42 months ago

New side note: The IR library will NOT work with Adafruits Neopixels or any digital LEDS. The timing MUST be so precise to control digital LEDS that interrupts must be put on hold while sending data to them. This means the IR can not pause code to capture the full pulses of an IR remote and decode them correctly. I have been working on my project for several days and just figured out why this would not work.
Your project CAN work with the IR Lib IF you only care that ANY IR signal was received. IE: because your processor was busy talking with digital LEDS it missed part of your IR button code. So you can't assign each button a different function, BUT you can say do something if you get ANY IR code. So just be aware of that.
I'm in the process of trying to implement something so when you press the button the first time, the digital LED code will stop for a moment and then read your real code and then continue. What this means is you have to press your button TWICE. Once to interrupt the code then again to read the CORRECT code... Not sure if this will work yet but that's the idea.. Just a heads up for folks this applies to anything with realtime Interrupts (like NeoPixels, and Servo motors.)

SteveR42 months ago

This was SOO much better than Adafruits tutorial that has massive arrays you have to capture and then use for each button. Normally they have the BEST stuff for easy understanding. HOWEVER this was by FAR the easiest for my remotes!! The library is about twice the size of the ada one BUT this is so much better I will take the loss on Flash for this ease!! :)
I only have one small glitch and it may just have to do with the remote I'm using BUT, if you click the remote too fast the read code loops forever. So the led just flashes all on it's own, until you do a long press on the remote. Again not sure if this is all remotes or just the one I chose. But I plan on adding this to my daughters Tiara project seen below. I want to cram a small tiny remote into a cheap wand, so the wand will control the Crown / Tiara.. Thanks AGAIN!! ~Steve~

FoamboardRC (author)  SteveR42 months ago
Hey thanks so much! I'm really glad that I was able to help you out!

Yeah actually it does the same thing for everyone. That was the main complaint I got because of the looping- it's not my library!

The fix is really simple, after the if statement {
if (results.value == X) }
add a small delay, like { delay(25); }.

This worked for me to keep it out of the loop, but don't put the delay too high. I forgot the actual milliseconds I used to fix it. If you go too high then sometimes when you press the button at the same time the arduino is frozen because of the delay. If you go too low then it doesn't fix the loop problem. Experiment, you'll get it.

And very nice project BTW!

Instead of cramming a remote into a wand you should just send a signal using an ATtiny85/45/44/24/ and the send feature of IR library.

I'm still here if you need any help with the IR part. . . :D

After beating my head against the wall for 20 mins trying to solve the flashing with the delay (Which I could not get to work) I found the PERFECT solution that works 100% everytime Change this line to:

if (results.value == 16236607) {results.value = 0; //Do something here}
By resetting the "results" back to 0 it cures the looping, because it can't "see" the correct value again until it gets the real code again from the sensor.
Thanks again you may want to update the code you shared with this correction and the problem is gone for good :)

FoamboardRC (author)  SteveR42 months ago

Duuude of course! I can't believe I didn't think of that! I never actually used the code (like in a project) other than testing it briefly for the i'ble. I'll go back and change it. Thanks! You could get really fancy and go with an ATtiny13-20SU. I just got a shipment of 20 in the mail! :D

Awesome thanks for the hints!!
Yeah no clue why I didn't think of just using the ATTiny!?!?!?! Perfect Idea!!!

ThiênN2 months ago

Hello FoamboardRC . In my case I wanna control more than 10 LEDs with an IR remote, that means the Arduino board can receive more than 1 digit from the remote at one time since the total number on the remote is not enough ( 0-9 : 10 number). For example: I want to turn on the 30th LED so I press 3, then 0 on the remote. Could you help me edit the code to make it works ?

1-40 of 166Next »