loading

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 [ 10/12/2015 ]

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 library called "RobotIRemote". This file will be in the Arduino program. Instructions for deleting this file is in step 3.

This library is for a specific robot 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
<p>JUST PERFECT!!!</p><p>Best Arduino related tutorial and &quot;instructable&quot; that I read so far, (and I assure you I read a lot).</p><p>Well organized, simple, straight forward, contains all what is required and with a light touch of humor.</p>
Thanks! I'm glad to help where I can!
<p>You are amazing, made my work so easy. Thanks alot :)</p>
<p>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!! :) <br>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~<iframe allowfullscreen="" frameborder="0" height="281" src="//www.youtube.com/embed/qCLX8vt_f0o" width="500"></iframe></p>
Hey thanks so much! I'm really glad that I was able to help you out!<br><br>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!<br><br>The fix is really simple, after the if statement {<br> if (results.value == X) }<br>add a small delay, like { delay(25); }. <br><br>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. <br><br>And very nice project BTW! <br><br>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. <br><br>I'm still here if you need any help with the IR part. . . :D
<p>hi i used:</p><p>results.value=0;</p><p>on the beginning of the void loop... fixed it for me :)</p>
<p>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:</p><p>if (results.value == 16236607) {results.value = 0; //Do something here}<br>By resetting the &quot;results&quot; back to 0 it cures the looping, because it can't &quot;see&quot; the correct value again until it gets the real code again from the sensor.<br>Thanks again you may want to update the code you shared with this correction and the problem is gone for good :) </p>
<p>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</p>
<p>Awesome thanks for the hints!! <br>Yeah no clue why I didn't think of just using the ATTiny!?!?!?! Perfect Idea!!!</p>
<p>Really Good Tutorial here bro. Finally made the IR sensor work! :D</p><p>But for some reasons, many of the links are not working properly. If would be awesome if you could fix those. </p><p>Anyway, Thanks for this! Really appreciate it as a beginner with Arduino! :)</p>
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.
<p>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. </p>
NP awesome! Good luck with the project!
<p>Sir,</p><p>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 &quot;led control using ir remote&quot;, 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.<br>Thank you once again,<br>regards </p><p>Nishant(INDIA)</p><p>:)</p>
<p>Sweet man! Good job! Keep up the good work!</p>
<p>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 :)</p>
<p>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!</p>
<p>So I'am new to arduino and i keep getting this when I try to upload the code to my arduino </p><p>Arduino: 1.6.7 (Windows 10), Board: &quot;Arduino/Genuino Uno&quot;</p><p>C:\Users\Nathan\AppData\Local\Temp\arduino_0358b079df29a873312a3e3bb140af8d\sketch_feb01a.ino: In function 'void loop()':</p><p>sketch_feb01a:38: error: 'FFE01F' was not declared in this scope</p><p> if (results.value == FFE01F) // change zero to your IR remote button number</p><p> ^</p><p>exit status 1</p><p>'FFE01F' was not declared in this scope</p><p>Invalid library found in C:\Program Files (x86)\Arduino\libraries\RemoteSketch: C:\Program Files (x86)\Arduino\libraries\RemoteSketch</p><p> This report would have more information with</p><p> &quot;Show verbose output during compilation&quot;</p><p> enabled in File &gt; Preferences.</p>
Put a zero X in front of it, like this: 0xFFE01F
<p>Very good instructable. I got this program working, but came across some Philips DVD remote control, that produces two different codes for the same button intermittently. Say if I press &quot;1&quot; it produces 3001 on the first press, then 13001 on the second press, then 3001 again on the third press and so on. I can catch the 3001 code in my program, but not the 13001 for some reason. I am comparing the received code respectively against 0x3001 and 0x13001. Maybe somebody came across this issue?</p>
<p>Great I'ble. Worked first try. Needed to read the remote codes of some outdoor lights so I can program my Arduino to control them all. Thanks for doing all the leg work for my project.</p>
<p>hi </p><p>Have you tried this on a attiny85. I have done something very similar which works fine on my uno but not on a tiny. </p>
No, because the library isn't supported by the ATtiny. It has to do something with the timers that aren't compatible.
OK thanks
<p>Hi am stuggeling with my project. Im making a IR Remote project and when reading the signal or number from a IR Remote and try to put it in my code it gives me an error that i have not declared it in the scope ? If anyone can help :)</p><p>code:</p><p>/*</p><p> * IRremote: IRrecvDemo - demonstrates receiving IR codes with IRrecv</p><p> * An IR detector/demodulator must be connected to the input RECV_PIN.</p><p> * Version 0.1 July, 2009</p><p> * Copyright 2009 Ken Shirriff</p><p> * http://arcfn.com</p><p> */</p><p>#include &lt;IRremote.h&gt;</p><p>int RECV_PIN = 11;</p><p>IRrecv irrecv(RECV_PIN);</p><p>decode_results results;</p><p>void setup()</p><p>{</p><p> Serial.begin(9600);</p><p> irrecv.enableIRIn(); // Start the receiver</p><p>}</p><p>void loop() {</p><p> if (irrecv.decode(&amp;results)) {</p><p> Serial.println(results.value, HEX);</p><p> if(results.value)</p><p> {</p><p> // HERE IS THE PROBLEM GIVES ME THIS ERROR : &quot;exit status 1</p><p>// FF02FD' was not declared in this scope&quot;</p><p> if(results.value == FF02FD)</p><p> {</p><p> }</p><p> }</p><p> irrecv.resume(); // Receive the next value</p><p> }</p><p> delay(100);</p><p>}</p><p>code</p>
You have to put a 0x (zero x) in front of those letters, so that would be <br><br>0xFF02FD
Thanks so much it worked.
<p>I'm getting this error massage whenever I going to compile IRemote</p><p>Arduino: 1.6.7 (Windows 7), Board: &quot;Arduino/Genuino Uno&quot;</p><p>C:\Program Files (x86)\Arduino\libraries\RobotIRremote\src\IRremoteTools.cpp:5:16: error: 'TKD2' was not declared in this scope</p><p> int RECV_PIN = TKD2; // the pin the IR receiver is connected to</p><p> ^</p><p>exit status 1</p><p>Error compiling.</p>
You didn't install the library correctly. Go back and read the instructions and it will work!
<p>can you please help me !</p><p>how can we again receive the ir command in middle of program to perform a function until that button is pressed and after that it stop.</p>
<p>Im getting this error for every ir remote labrary. what should i do</p><p>In file included from C:\Users\Akshay\Documents\Arduino\libraries\IRremote\IRremote.cpp:13:0:</p><p>C:\Users\Akshay\Documents\Arduino\libraries\IRremote\IRremoteInt.h:15:22: fatal error: WProgram.h: No such file or directory</p><p> #include &lt;WProgram.h&gt;</p><p> ^</p><p>compilation terminated.</p>
You didn't install the library in the correct place. Reread the install instruction for the library.
<p>i am using TV remote to control my motor but i am getting an error can anyone fix it.</p><p>Also, after long pressing the button getting , i am getting a no. repeated for long press ,which is different than the first one. </p><p>#include &lt;IRremote.h&gt;</p><p>//ONKYO Remote</p><p>int RECV_PIN = 11; //Pin 11 is for the IR remote</p><p>IRrecv irrecv(RECV_PIN);</p><p>decode_results results; // The name of the decode_results function</p><p>int led = 13; // Pin 13 is for the builtin</p><p>LED on the arduino</p><p>const int Motor1Pin1 = 7; // Pins for the motors so 7, 6, 5, 4</p><p>const int Motor1Pin2 = 6;</p><p>const int Motor2Pin1 = 5;</p><p>const int Motor2Pin2 = 4;</p><p>void setup() {</p><p>irrecv.enableIRIn();</p><p>pinMode(led, OUTPUT); // OUTPUT the LED</p><p>pinMode(Motor1Pin1, OUTPUT); // OUTPUT the motor pins</p><p>pinMode(Motor1Pin2, OUTPUT);</p><p>pinMode(Motor2Pin1, OUTPUT);</p><p>pinMode(Motor2Pin2, OUTPUT);</p><p>}</p><p>void loop() {</p><p>digitalWrite(led, HIGH); // When the arduino is ready to get commands the LED will turn on</p><p>if(irrecv.decode(&amp;results)) { // if the arduino receives a signal from the remote...</p><p>irrecv.resume();</p><p>if(results.value == 0x4BB641BE) { // Here's where you need to change the value from</p><p>4BB641BE to the one in your serial monitor but always put 0x before the value (the number zero</p><p>and the letter x)</p><p>moveForward(); // move forward</p><p>}</p><p>else if(results.value == 0x4BB6C13E) { // Change the value for the Backward</p><p>moveBackward();</p><p>}</p><p>else if(results.value == 0x4BB621DE) { // Change the value for the Left</p><p>moveLeft();</p><p>}</p><p>else if(results.value == 0x4BB6A15E) { // Change the value for the Right</p><p>moveRight();</p><p>}</p><p>else if(results.value == 0x4BB6E916) { // Change the value for the Stop</p><p>Stop();</p><p>}</p><p>}</p><p>}</p><p>// voids for all the mouvement. If it doesnt work for you please feel free to change it</p><p>void moveForward() {</p><p>digitalWrite(Motor1Pin2, HIGH);</p><p>digitalWrite(Motor1Pin1, LOW);</p><p>digitalWrite(Motor2Pin2, LOW);</p><p>digitalWrite(Motor2Pin1, HIGH);</p><p>}</p><p>void moveBackward() {</p><p>digitalWrite(Motor1Pin1, HIGH);</p><p>digitalWrite(Motor1Pin2, LOW);</p><p>digitalWrite(Motor2Pin1, LOW);</p><p>digitalWrite(Motor2Pin2, HIGH);</p><p>}</p><p>void moveLeft() {</p><p>digitalWrite(Motor1Pin1, LOW);</p><p>digitalWrite(Motor1Pin2, HIGH);</p><p>digitalWrite(Motor2Pin2, HIGH);</p><p>digitalWrite(Motor2Pin1, LOW);</p><p>}</p><p>void moveRight() {</p><p>digitalWrite(Motor1Pin2, LOW);</p><p>digitalWrite(Motor1Pin1, HIGH);</p><p>digitalWrite(Motor2Pin1, HIGH);</p><p>digitalWrite(Motor2Pin2, LOW);</p><p>}</p><p>void Stop(){</p><p>digitalWrite(Motor1Pin2, LOW);</p><p>digitalWrite(Motor1Pin1, LOW);</p><p>digitalWrite(Motor2Pin1, LOW);</p><p>digitalWrite(Motor2Pin2, LOW);</p><p>}</p>
You didn't look at all your errors, there are a ton of them. <br><br>You messed up on the { and }'s. I can't even get to the bottom of it. I suggest you re-write your code and make sure you get all of the curly braces properly placed. You need to make sure this an } for every {. <br><br>Instead of using a bunch of else if's use switch /case, it'll make things a lot simpler.
<p>Here the error which i am getting:</p><p>Stray '/315' in program</p>
<p>Perfect tutorial :D , Can you please make a tutorial about sending IR signals (for Ex. Controlling your tv from Arduino)</p>
I have plans to make one sometime soon. Subscribe :D
<p>I really liked the way you have presented the instructable and immediately got on with it. But, I need your help with this seemingly impossible problem(even though i know nothing is impossible). Now, the problem here is that the remote im trying to mimic is a DTH(set top box) remote. I'm not sure if you are familiar with this term but in India, we have a separate cable connection which isn't really good. So, we use set-top boxes or DTH connections from other private companies. My TV is of Sony brand and I was able to control it by decoding the protocol using other arduino sketches, but this DTH remote had a different and weird protocol. I had given up on it weeks ago when i saw this 'ible.</p><p>So, when i press the power button on it, here is what comes out in the serial monitor-</p><p>3561026746</p><p>3988242308</p><p>3561026746</p><p>294785661</p><p>3561026746</p><p>108254234</p><p>3340940085</p><p>108254234</p><p>3340940085</p><p>108254234</p><p>3561026746</p><p>108254234</p><p>3561026746</p><p>108254234</p><p>3340940085</p><p>108254234</p><p>While this does have a certain pattern to it, it is nothing like what you have described. Here is another example, the volume up button -</p><p>3340940085</p><p>4119049988</p><p>3561026746</p><p>4233435820</p><p>3561026746</p><p>4233435820</p><p>3561026746</p><p>4233435820</p><p>3561026746</p><p>4233435820</p><p>3561026746</p><p>4233435820</p><p>3340940085</p><p>4233435820</p><p>3340940085</p><p>4233435820</p><p>3561026746</p><p>4233435820</p><p>3561026746</p><p>4233435820</p><p>3561026746</p><p>4233435820</p><p>2767527081</p><p>4233435820</p><p>Now, I had to cross-check to see if there was a problem with the code or with the remote, so i tried using the sony remote's power button-</p><p>2704</p><p>2704</p><p>2704</p><p>2704</p><p>Same thing repeating, now, volume up,</p><p>1168</p><p>1168</p><p>1168</p><p>1168</p><p>Again. </p><p>Weird isn't it? But since I have done it earlier, mimicking the Sony protocol isn't really a big problem. To change channels and do all the proper stuff i need the DTH remote. And, to top it all the DTH companies aren't even international that I'd be included in a considerably large amount of people trying to do what I am doing so that there could be many of us working to solve the problem. I don't understand how to accommodate the code flowing in with the other sketches given by you.</p><p>Please help me I would be extremely grateful to you.</p><p>Thanks.</p>
Hi!<br><br>I noticed you dropped a comment on my IR instructable yesterday. So let me try to understand this:<br><br>You have 2 different remotes, a Sony one and then a DTH one. The Sony remote works fine, (gives the same number every time you press the same button), but the DTH remote does that seemingly random pattern? I mean there are some repeats in the numbers but they are spaced differently. <br><br>When you say you press the power button do you mean you are doing that repeatedly or are you holding the button down?<br><br>~AJ<br>
Thanks for the prompt reply!<br>Yes, you have got it right. When I press the power button I hold it down for say, 2 seconds, and then release.<br>Also. as you might have noticed, by the end, there is a pair of repeating numbers. When I pressed it for a longer time, those numbers keep on repeating in the same way.
<p>*I mean the last pair of numbers repeat. The code I have given is trimmed off some of the last few recurring pairs.</p>
<p>I'm getting tad confused lol! Every time you short press the mode button on the DHT remote, do you get the same first number?</p>
<p>Yep. The first number is same when I press the same button twice. But for two different buttons it obviously isn't. </p>
<p>This tutorial was just perfect the best one out of many that I saw online.</p><p>Thanks</p>
<p>Hello <a href="http://www.instructables.com/member/FoamboardRC/" rel="nofollow">FoamboardRC</a>,</p><p>I used couple of others IR examples and yours example too. its great.</p><p>However i have few concerns. I want to reverse the IR data when it is received at adruino. Suppose i am sending following Pulse duration code as follows (Samsung volume up) </p><p>4394,4368,546,1638,546,1638,546,1638,546,546,546,546,546,546,546,546,546,546,546,1638,546,1638,546,1638,546,546,546,546,546,546,546,546,546,546,546,1638,546,1638,546,1638,546,546,546,546,546,546,546,546,546,546,546,546,546,546,546,546,546,1638,546,1638,546,1638,546,1638,546,1638,546,46644,4394,4368,546,546,546,96044</p><p>Adruino receives it fine, but it decodes it as follows</p><p>6538,4500,-4300,500,-1650,500,-1700,500,-1700,500,-550,650,-450,600,-500,650,-450,600,-500,600,-1600,600,-1550,650,-1550,600,-500,550,-550,600,-500,550,-500,650,-450,600,-1600,550,-1650,500,-1700,500,-550,650,-450,550,-550,650,-450,550,-550,600,-500,550,-500,650,-450,600,-1600,550,-1650,500,-1700,500,-1650,500,-1700,500</p><p>i used &quot;IRrecvDump.pde&quot; sketch from the attached lib. could you please give me some direction how to reverse the exact code by adruino OR whats the wrong with this sketch??</p><p>I am new to adruino. but understand the basic functionality...</p>
<p>I've never used that example, so I'm not sure how to use it. I have no clue how to send stuff. </p>
<p>its not about sending stuff actually. Its about receiving at adruino side.</p><p>This example uses same api irrecv.decode() to receive IR data.</p><p>I want to decode that data in integer array of 74.</p><p>This lib of ken Shirriff decodes tha data into array of 68. But values are wrong.</p>
<p>Like I said, I have no clue :)</p>
<p>its not about sending stuff actually. Its about receiving at adruino side.</p><p>This example uses same api irrecv.decode() to receive IR data.</p><p>I want to decode that data in integer array of 74.</p><p>This lib of ken Shirriff decodes tha data into array of 68. But values are wrong.</p>
<p>Hi <a href="http://www.instructables.com/member/FoamboardRC/" rel="nofollow">FoamboardRC</a>,</p><p>Please guide me with some directions.</p><p>I want to reverse the code when it is received on the adruino.</p><p>Basically when i am sending pulse duration from remote to adruino, adruino should reverse it back to the same int array.</p><p>i am sending </p><p>4394,4368,546,1638,546,1638,546,1638,546,546,546,546,546,546,546,546,546,546,546,1638,546,1638,546,1638,546,546,546,546,546,546,546,546,546,546,546,1638,546,1638,546,1638,546,546,546,546,546,546,546,546,546,546,546,546,546,546,546,546,546,1638,546,1638,546,1638,546,1638,546,1638,546,46644,4394,4368,546,546,546,96044,</p><p>But adruino is decoding it as follows</p><p>6538,4500,-4300,500,-1650,500,-1700,500,-1700,500,-550,650,-450,600,-500,650,-450,600,-500,600,-1600,600,-1550,650,-1550,600,-500,550,-550,600,-500,550,-500,650,-450,600,-1600,550,-1650,500,-1700,500,-550,650,-450,550,-550,650,-450,550,-550,600,-500,550,-500,650,-450,600,-1600,550,-1650,500,-1700,500,-1650,500,-1700,500,</p>

About This Instructable

370,557 views

358 favorites

License:

Bio: ¿Qué tal? I'm 16 and enjoy learning about electronics. I am self-taught. I love programming my Arduino and soldering circuits. My newest hobby is ... More »
More by FoamboardRC: Control Your RC Plane With Your Phone's Acclerometer DIY Receiver Controlled Switch (Cheap and Easy) Complete Guide to Building Your First RC Foamboard Plane
Add instructable to: