loading
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 [ 03/31/2015 ]

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.

IMPORTANT NOTICE:

With the latest release of the Arduino IDE there is a conflicting library that renders this tutorial void. If you'd still like to use this tutorial delete the file called "RobotIRemote". This file will be in the Arduino program.

This library is for a specific robot shield that Arduino/venders sell. Unless you intend on buying that shield you can delete that folder and continue with this set of instructions. You can always download it again later!

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.

 
1-40 of 211Next »
SteveR48 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)  SteveR48 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

hi i used:

results.value=0;

on the beginning of the void loop... fixed it for me :)

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)  SteveR48 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!!!

tnowroz4 months ago

Really Good Tutorial here bro. Finally made the IR sensor work! :D

But for some reasons, many of the links are not working properly. If would be awesome if you could fix those.

Anyway, Thanks for this! Really appreciate it as a beginner with Arduino! :)

FoamboardRC (author)  tnowroz4 months ago
Thanks! I'm not sure what you are talking about the links though. I just went through and checked all of them and they are all working. Maybe you might just have to copy the address and paste it in your browser's address bar.
UrbanErosion made it!6 months 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
FoamboardRC (author)  UrbanErosion5 months ago
NP awesome! Good luck with the project!
nreahal made it!1 year 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)  nreahal11 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)  nreahal11 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!

giladgberg8 days ago

thank's man !

do you know how can i manage to copy the signal?

say i want to make a smart home and with a singel ir sender i need to control several instruments....

skumar2311 month ago

hi frnds i made this but..i have a question that if i connect a five volt dc motor directly to the arduino pins so what happen...is arduino damageg

SeoT11 month ago
Gibz731 month ago

Hi there, thank you for this, but I have one question. How would I have a task loop until a different button is pushed on remote? Im using switchState and have 3 different tasks. I want each task to loop until a different button is pressed. My code so far;

#include <IRremote.h>

int IRpin = 11; // pin for the IR sensor
int ledPins[] = {3, 4, 5, 7, 6, 8, 9, 12, 10, 13 }; // an array of pin numbers to which LEDs are attached
int pinCount = 10; // the number of pins (i.e. the length of the array)
int brightness = 0; //How bright the LED is
int fadeAmount = 5; //How many points to fade LED by
int timer = 60; // The higher the number, the slower the timing.

IRrecv irrecv(IRpin);
decode_results results;

boolean LEDon = true; // initializing LEDon as true

void setup()
{
Serial.begin(9600);
irrecv.enableIRIn(); // Start the receiver
for (int thisPin = 0; thisPin < pinCount; thisPin++) {
pinMode(ledPins[thisPin], OUTPUT);
}
}

void loop()
{

if (irrecv.decode(&results))
{

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

switch(results.value)
{

case 29876577:

// do this
for(int i=0; i<10; i++)
analogWrite(ledPins[i], brightness); //Set brightness of RedLED1
brightness = brightness + fadeAmount; //Change brightness for nex time through loop

if (brightness == 0 || brightness == 255){ // reverse the direction of the fading at the ends of the fade:

fadeAmount = -fadeAmount;
}
delay(100);

break;

case 1632469053:
// do another thing
for (int thisPin = 0; thisPin < pinCount; thisPin++) { // loop from the lowest pin to the highest:
digitalWrite(ledPins[thisPin], HIGH); // turn the pin on:
delay(timer);
digitalWrite(ledPins[thisPin], LOW); // turn the pin off:
}

for (int thisPin = pinCount - 1; thisPin >= 0; thisPin--) { // loop from the highest pin to the lowest:
digitalWrite(ledPins[thisPin], HIGH); // turn the pin on:
delay(timer);
digitalWrite(ledPins[thisPin], LOW); // turn the pin off:
}
break;

case 482085517:
// feed my dog for me
digitalWrite(ledPins[0], HIGH);
digitalWrite(ledPins[2], HIGH);
digitalWrite(ledPins[4], HIGH);
digitalWrite(ledPins[6], HIGH);
digitalWrite(ledPins[8], HIGH);
delay(100);
digitalWrite(ledPins[0], LOW);
digitalWrite(ledPins[2], LOW);
digitalWrite(ledPins[4], LOW);
digitalWrite(ledPins[6], LOW);
digitalWrite(ledPins[8], LOW);
digitalWrite(ledPins[1], HIGH);
digitalWrite(ledPins[3], HIGH);
digitalWrite(ledPins[5], HIGH);
digitalWrite(ledPins[7], HIGH);
digitalWrite(ledPins[9], HIGH);
delay(100);
digitalWrite(ledPins[1], LOW);
digitalWrite(ledPins[3], LOW);
digitalWrite(ledPins[5], LOW);
digitalWrite(ledPins[7], LOW);
digitalWrite(ledPins[9], LOW);
break;

default:
for (int thisPin = 0; thisPin < pinCount; thisPin++) {
digitalWrite(ledPins[thisPin], LOW);
}
}
}

Sadly, when i press button on remote it only does the case 1 time, any ideas please?

FoamboardRC (author)  Gibz731 month ago

Try getting rid of the break; at the end of the statements.

ghall11 month ago

Hey there! I was wondering if there is a way to get the raw data that the IR sensor receives? convert your number codes into Hex codes?

I want to record the codes with an arduino and use my smartphone to transmit them so i can control my Air conditioning.

If you can help at all it would be greatly appreciated.

FoamboardRC (author)  ghall11 month ago

Chat it up on the forums, I can't help :D

http://www.righto.com/2009/08/multi-protocol-infrared-remote-library.html

Maybe it's because I am using Arduino IDE 1.6.4 but when I move on to Step 6: Arduino Test Code and change the zero in the line of code: if (results.value == 0) to FF30CF I get an error - 'FF30CF' was not declared in this scope . Which is probably an easy issue to resolve but I am still an Arduino coding newbie. So time to do my homework. But thank you for a great Instructable.

Basic Setup.JPG

Maybe it because I'm using Arduino IDE 1.6.4 but in the sketch in Step 6: Arduino Test Code - when I change the zero to FF30CF I get the error - 'FF30CF' was not declared in this scope. Probably a simple to fix issue? I'm still fairly new to coding in Arduino so I'll do my homework but wanted to point it out. Thank you for a very good Instructable.

DIshendra3 months ago

Hi Friend! I am in a small trouble. I had tried many ways to decode the signals (from adafruit's tutorial to your tutorial and irRemote also) but every time i press a key the decoded data is different.

Capture.JPG

Use the first number you get.

If it does not work use all numbers with an or operator in the if statement.

I hope it works.

FoamboardRC (author)  DIshendra3 months ago
It has to be your remote then. Pick up a different remote from the dollar store and try it out!
Thanks friend for quick reply. But i had tried sony, voltas, hathway, samsung remotes but every time generating a different output.
FoamboardRC (author)  DIshendra3 months ago

Chat it up on the forums.

yorams662 months ago
kjn46852 months ago
I really appreciate when somebody takes the time to share their knowledge. Thank you formboradrc
FoamboardRC (author)  kjn46852 months ago
No problem! I'm glad I can help!
WilliamM203 months ago

Great tutorial,

only problem is that the arduino does not register the IR while battery powered, only while it's connected to the pc. Any tips?

FoamboardRC (author)  WilliamM203 months ago
uh what kind of battery are you using?

I'm using a 6V battery pack, I read that the ideal input voltage is 9-12V but will it effect the arduino so much?

FoamboardRC (author)  WilliamM203 months ago

No it shouldn't. I'm not sure. What do you mean by it's not registering IR

Since I can't use the serial monitor while battery powered I do not know if it is registering the IR signals or not. But if it would it should work fine

FoamboardRC (author)  WilliamM203 months ago

One more thing you can try. Take out the servo. Sometimes they can draw too much power and cause the system to keep restarting. So try the code with the servo totally unplugged. Let me know how that goes

Sadly taking out the servo didn't help

FoamboardRC (author)  WilliamM203 months ago

Low voltage isn't a problem because a USB port is only 5 volts whereas you said you were giving it 6. I'd just completely start over with your project. Maybe your Arduino is broken. Sorry I can't help anymore!

I started over and now it works :)

1-40 of 211Next »