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 137Next »
nreahal made it!7 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)  nreahal2 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)  nreahal2 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!

SteveR43 days 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.)

SteveR49 days 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)  SteveR48 days 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)  SteveR45 days 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ênN16 days 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 ?

FoamboardRC (author)  ThiênN16 days ago
Hey! So I'm super busy but and it would take me quite a while to get that code down. Why don't you ask it as a question in our forums. There are some really great guys there!

Thanks for this awesome tutorial! I was able to set up my IR kit with my Arduino Uno quickly and easily. I was able to control two LEDS, and I am now planning on making an RC Arduino Tankbot, or automating some stuff.

FoamboardRC (author)  nrobinson200016 days ago
Awesome!! Glad I could help!
DonEduardo1 month ago

Yeah, best, fastest way to actually doing something with an IR sensor. I've been reading on this subject off and on for a couple years each time saying forget it. Gave this a shot and a few minutes later I'm reading codes on two random remotes. Thanks much.

FoamboardRC (author)  DonEduardo1 month ago
Yeah i had the same problems as you before! Thats why I made these instuctions. I'm glad I could help!
IvyL1 month ago

Thanks the zip file helped out a lot

Crzy.Rio1 month ago

Wondering if there is an easy way to allow output the signal to an IR Transmitter?

Once I read all the values from the remote, can I then use the Arduino to control my TV?

kannanravi286 months ago
I am using remote as just like , you have suggested in Spark fun . everything works fine. But if I use ususal TV remote , and press the button , I get continuously same value. First and second numbers are same and it continuous. How to solve this?

I ran into the same problem as you!

One way around this is to hold down the button when pressing so the 2nd command is also sent "4294967295". That was it is the 2nd command that keeps repeating.

FoamboardRC (author)  Crzy.Rio1 month ago

Ok so it sounds like you want your car to move forward a few inches every time you press the button. Try adding a 50ms delay in there to stop the sensor from reading. Then when you press the same button again it should return with the first value. Actually what might work is if you cleared remote.value (set it to zero) after the code to make the car move. So it might look like this. . .

if (results.value == random##)

{

moveCar(forward);

delay(50);

results.value = 0;

}

That way the sensor would have to take a new reading.

Thank you very much! I did not think of resetting the results value.

And once again thanks for the awesome tutorial

FoamboardRC (author)  kannanravi286 months ago

Well then what's the problem? If you get the same number over and over then it'll just repeat the command like it should!

First off thanks a lot for the tutorial, helped a lot! :)

But I too am having it behave similarly as he described. I am using a remote to control a Arduino powered car and want the car moving 100mm only when the button is pressed, so if that command keeps coming it will go on forever :P.

However, at the same time if that is pressed again I want the car to move another 100mm. As I stated above, If the key is held down then the 2nd "4294967295" value shows up so it changes.

I was wondering thought if you have any input as to why that happens? If I press the play button for example and then hide the remote out of view, I constantly see the same play code running over and over again in the serial monitor even though nothing is being sent to the sensor.

matys2923 months ago

Hello, i have tryed more than 5 remotes and on all im getting numbers everytime i press changed. I tryed on low budget remotes and on expensive one too but same story.. My number is not stable at all :S Please help me

Ran into a similar problem and it turned out it was a faulty IR Detector. Which one are you using ?

FoamboardRC (author)  matys2922 months ago

Hmm... I would check you wiring, and most definitely your IR receiver. Try a new one and make sure the pinout is correct. They can be tricky at times.

dankaraji2 months ago

hey man...your instructions were amazing..i finally understood how the whole remote thing works

i have a question though..im actually trying to use the remote control to communicate with my computer keyboard..

i mean for example if i press one button on the remote it would work as if is pressed lets say button (F) on my computer

im new with arduino so i would really appreciate your help...

FoamboardRC (author)  dankaraji2 months ago
Unfortunately dank, I can't help you with that. Ask in the forums. Communication over a USB port is not my area

hello,

this is amazing, really helpfull. but now i got a question. am i able to keep an output high until i realease the button? because every butten gives after the first code the same code if you keep it pressed?

maybe a stupid question, but im a beginner in arduino :P

thank you,

FoamboardRC (author)  Mistercrazyboy21.2 months ago

Hey man! No, the only dumb question is the one not asked.

The first little bit of code I gave works as a toggle, so it stays on. Once you press the button that same pin will stay high until you press it again. Follow the link below. Is that what you wanted?

http://www.mediafire.com/view/hmv13ynbihed0eg/Test_LED.ino

hey man,

thanks a lot for the code, but it isnt really what im looking for, because i would like to power a motor and when i press the button the motor runs and when i release the button the motor stops running.

thanks a lot for the quick response :D

FoamboardRC (author)  Mistercrazyboy21.2 months ago

Oh I gotcha! Okaydokey, give me a minute to think. . . when you hold down your remote button does it give you a continues value that repeats itself like the one shown in the image of step 5?

What I'm trying to say is when you hold down the button, in the serial monitor, you see an initial number, then another number that repeats itself like this:

16753245
4294967295
4294967295
4294967295

In that case give me a day and I'll cook up some code for you.

okey, no problem. take your time. its amazing that you repeat that quickly and are this motivated to help people. so take your time. compliments for you!

FoamboardRC (author)  Mistercrazyboy21.2 months ago

And thank you very much, I love helping out where I can.

GRRR. . . I spent 2 hours trying to get this code to work, but I can't seem to nail it down! :(

Try asking it in the forums. I can't really get it to work. I got close, but not close enough. Your motor would be pulsing with my code :D

I'll try again after I finish school, but . . . I dunno! It seams so simple!


KevinAI3 months ago

Ok I have been trying every IR Library available and I dont seem to make any work. All I get in the serial monitor is zeros each time I press a button on my remote. My Devices are U-verse box, and Samsung TV

Kevin

FoamboardRC (author)  KevinAI2 months ago

If you've tried all the libraries it's time to start looking for a hardware problem. Check wiring, your Arduino, and try another receiver.

elisegc3 months ago

So helpful. Thank you!

FoamboardRC (author)  elisegc3 months ago
Glad I could help!
steinie449 months ago

The fix:

irrecv.resume(); // Receive the next value

belongs at the end if the

if (irrecv.decode(&results))

here is a example:

[code]
/*
DVR IR Receiver 03 March 2014 JDS
* See: http://www.instructables.com/id/The-Easiest-Way-to-Use-Any-IR-Remote-with-Ardiuno/?ALLSTEPS

The IR sensor's pins are attached to Arduino as so:
Pin 1 to Vout (pin 11 on Arduino)
Pin 2 to GND
Pin 3 to Vcc (+5v from Arduino)
*/

#include <IRremote.h>

int IRpin = 11; // pin for the IR sensor
int LED = 13; // LED pin
IRrecv irrecv(IRpin);
decode_results results;

boolean LEDon = true; // initializing LEDon as true

void setup()
{
Serial.begin(9600);
irrecv.enableIRIn(); // Start the receiver
pinMode(LED, OUTPUT);
}

void loop()
{
digitalWrite(LED, LOW);
if (irrecv.decode(&results))
{

// irrecv.resume(); // Receive the next value


switch(results.value)
{
case 16720350:
Serial.println("MULT");
break;

case 16763190:
Serial.println("POWER");
break;

case 16716270:
Serial.println("SEARCH");
break;

case 16714230:
Serial.println("|<");
break;

case 16718310:
Serial.println("||<");
break;

case 16724430:
Serial.println("|>");
break;

case 16728510:
Serial.println(">||");
break;

case 16726470:
Serial.println(">>");
break;

case 16761150:
Serial.println(">|");
break;

case 16771350:
Serial.println("ADD");
break;

case 16746870:
Serial.println("FN");
break;

case 16742790:
Serial.println("MENU");
break;

case 16767270:
Serial.println("Left");
break;

case 16750950:
Serial.println("Right");
break;

case 16755030:
Serial.println("Up");
break;

case 16734630:
Serial.println("Down");
break;

case 16769310:
Serial.println("1");
break;

case 16736670:
Serial.println("2");
break;

case 16752990:
Serial.println("3");
break;

case 16765230:
Serial.println("4");
break;

case 16732590:
Serial.println("5");
break;

case 16748910:
Serial.println("6");
break;

case 16773390:
Serial.println("7");
break;

case 16740750:
Serial.println("8");
break;

case 16757070:
Serial.println("9");
break;

case 16730550:
Serial.println("0");
break;

case 16738710:
Serial.println("ESC");
break;

case 16722390:
Serial.println("-/--");
break;

default:
digitalWrite(LED, HIGH);

}
irrecv.resume(); // Receive the next value
}

}


[/code]

1-40 of 137Next »