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 ]
 
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 96Next »

can you upload any video to show me how do it practical

kshowell1 month ago

Very helpful Instructable, Thank You

FoamboardRC (author)  kshowell1 month ago
Glad you understood! Yup!
filip_os1 month ago

HI FoamboardRC, i found bug (i guess). I am controlling LED with remote controller with PWM, and i realized something weird. PWM pins 3,5,6,9 and 10 are working OK but pin 11 is not working. If i set value between 0-255 programs stops, and pin gets value 0. Is the problem in the library?

Can you help me with this problem. Than you in advance !

FoamboardRC (author)  filip_os1 month ago

Hey! Sorry I thought I had already replied to this! Sorry! Anyways is it something to do with your Arduino? Try making a standard fade program using PWM and see how that works, and get back with me.

omnacron1 month ago

hello im having a little trouble with trying to get the codes off of my dishnetwork remote. i have everything hooked up correctly and i tested the IR receiver to make sure it work after hours of searching and frustration i finaly found a library and sketch that didnt have errors. but nothing comes up on my serial window i know the remote and the receiver works. any help would be accepted thank yhou

FoamboardRC (author)  omnacron1 month ago

Why don't you give me a link to your code or PM me it and let me check it out?

jhong23881 month ago

can u help me with codes i want to control my servo using ir?

FoamboardRC (author)  jhong23881 month ago
How do you want to control it? Explain. Do you want on button to make it go by increments or you press a button and it assumes a degree of rotation.
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?
FoamboardRC (author)  kannanravi281 month 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!

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?
shinystuff2 months ago

Thank you for this tutorial. It really helped me to understand how to work with IR receivers. Very well done! I

FoamboardRC (author)  shinystuff2 months ago

Glad I could help!

kminton34 months ago

I cant get the switch cases to work like the last LED test the LED just stays on and shuts off for a brief moment when i press a remote button heres the code:

#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()

{

if (irrecv.decode(&results))

{

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

}

switch(results.value)

{

case 1637875967:

if (LEDon == true) // is LEDon equal to true?

{

LEDon = false;

digitalWrite(LED, HIGH);

delay(100); // keeps the transistion smooth

}

else

{

LEDon = true;

digitalWrite(LED, LOW);

delay(100);

}

FoamboardRC (author)  kminton32 months ago

You are missing all the break statements. add break; at the end of every case statement.

FoamboardRC (author)  kminton34 months ago

This my code and I know that it works, so you must be doing something wrong. Make sure you open up Serial Monitor and see what's going on in there. What do the numbers look like? What numbers are shown when you press a button on your remote?

FoamboardRC (author)  FoamboardRC4 months ago

You are also missing the break; statement

nreahal made it!2 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
pattongu2 months ago

Thank you for taking the time to share your knowledge.

oze_mal2 months ago

the only "issue" I had with your instructable

The zip file when downloaded from https://github.com/shirriff/Arduino-IRremote is named IR Ible Package.zip

the directions should say something to the effect

check to see if you already have an arduino\libraries\IRremote directory if you do move it out of the libraries to arduino\old_libraries\

unzip the library.zip to the arduino\libraries directory then if necessarry rename the directory to IRremote


The code worked a treat and I was able to get all codes from my remotes.
Thanks

Microbe3 months ago

Thanks great 'ible. Any ideas on this error? I don't see where it is even calling RobotIRremote unless it is inside IRremote.h

Arduino: 1.5.6-r2 (Windows 8), Board: "Arduino Leonardo"

Using library Robot IR Remote in folder: C:\Program Files (x86)\Arduino\libraries\RobotIRremote

C:\Program Files (x86)\Arduino\libraries\RobotIRremote\src\IRremoteTools.cpp:5: error: 'TKD2' was not declared in this scope

Microbe Microbe3 months ago

SOLUTION: Use IDE 1.0 not 1.5

evikartika3 months ago

I've installed the IRremote library. Opened IR Decode, compiled and uploaded to Arduino. All looks as it should yet nothing prints in the serial monitor. I've tried ALL the baud rates (although I imagine you used 9600) yet the issue persists.What should i do??i have been stuck here..please help me..

FoamboardRC (author)  evikartika3 months ago

PM me your code.

i've used your IR Decode sketch to get the recognizing IR signal and follow the step given,nothing wrong when i uploaded the sketch..but the problem is when nothing prints in the serial monitor.

#include <IRremote.h>

int IRpin = 11;

IRrecv irrecv(IRpin);

decode_results results;

void setup()

{

Serial.begin(9600);

irrecv.enableIRIn(); // Start the receiver

}

void loop()

{

if (irrecv.decode(&results))

{

Serial.println(results.value, DEC); // Print the Serial 'results.value'

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

}

}

FoamboardRC (author)  evikartika3 months ago

OK I used your code and everything works fine for me. Please refer to the last step for trouble shooting. If you still have trouble you may have issues with your serial monitor. Try making another project and see if you can print to the serial.

Okay..its work!!tq so much..i can smile now.. :-)
zulkola4 months ago

why my button number keep changes, sometimes 16720605, sometimes 50470553..it is not stable..why?

FoamboardRC (author)  zulkola4 months ago
I can't be sure maybe you just have a really cheap remote, its malfunctioning, or there's interference.

What I would do is to use a switch/case statement for both numbers but have them do the same thing, so no matter which of the two numbers comes out, it'll do the same thing.

That help a little?
steinie444 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]

wildbananas5 months ago

As promised I learnt this in a few minutes, thanks to all the links within,

kleinjm5 months ago

Great job! Much simpler than what I have been doing. Thanks!

FoamboardRC (author)  kleinjm5 months ago
Awesome! Glad I could help!
visakan225 months ago

Hi, Thanks for a good tutorial. It works great. But I am unable to use pin 8 or pin 0 on my Uno (there is no signal and Tx led does not flash). Any thing special about pin 11?. Thanks again.

FoamboardRC (author)  visakan225 months ago
Did you re-write this line to other pins?

int IRpin = 11; // pin for the IR sensor

change to

int IRpin = 8; // pin for the IR sensor

Other than that I'm pretty sure that the library is written for reading only on pin 11. You'd have to go into the library code itself and change it. I'm not sure how to do that.
skeedes9 months ago
hi, thanks a lot for the simple tut. a lot of heavy lifting gets done by the library!
but i have one issue i want to solve-

In the switch-case code you have shared, i have put a serial.println line in each of the 'case' sections. it shows the 'case' getting called even when i am not pressing the remote button anymore. it only changes once i press another button. how to avoid that? thanks


FoamboardRC (author)  skeedes9 months ago
Hey!

Are you forgetting to put 'break;' at the end of each case?
Hi

The breaks are there, please see the sketch below.
The problem seems to be in the 'delay' statement in the last line. Value below 1000 is causing the sensor to frequently go into a loop, repeating the same code in the serial monitor. Keep the value low like 100 or so, and you can see the result. Can my IR sensor be bad? Or do I need to pull down or something?
Thanks!

/*
* Sketch modified by Enjoying Electronics: http://www.instructables.com/member/Enjoying+Electronics/
Code based off of:
* IRremote
* Version 0.1 July, 2009
* Copyright 2009 Ken Shirriff
* For details, see http://arcfn.com/2009/08/multi-protocol-infrared-remote-library.html

* Special thanks to dablondeemu http://www.instructables.com/member/dablondeemu/
* and his instructable listed below, IR Remote Controlled Color Changing Cloud (Arduino)
* http://www.instructables.com/id/IR-Remote-Controlled-Color-Changing-Cloud-Arduino/


* Lets get started:

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

int IRpin = 11; // pin for the IR sensor

IRrecv irrecv(IRpin);
decode_results results;


// IR buttons STB remote #1
const long int uparrow = 2153764903;
const long int downarrow = 2153773063;
const long int rightarrow = 2153732263;
const long int leftarrow = 2153740423;
const long int okbutton = 2153765413;


/*
// IR buttons univ remote #2

const long int uparrow = 484659885;
const long int downarrow = 484651725;
const long int rightarrow = 484692525;
const long int leftarrow = 484676205;
const long int okbutton = 484661415;

*/

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

void loop()
{
if (irrecv.decode(&results))
{
irrecv.resume(); // Receive the next value
}

switch(results.value)
{

case uparrow: // up arrow
Serial.println(results.value, DEC);
break;

case downarrow: // down arrow
Serial.println(results.value, DEC);
break;

case rightarrow: // right arrow
Serial.println(results.value, DEC);
break;

case leftarrow: // left arrow
Serial.println(results.value, DEC);
break;

case okbutton: // ok button
Serial.println(results.value, DEC);
break;

delay(100);
}

}
FoamboardRC (author)  skeedes7 months ago
(removed by author or community request)
1-40 of 96Next »