So. This Instructable will show you how to control anything controllable by IR, or Infrared light.

This includes cameras, TV's, DVD players, VCR's, you get the point.

I will be showing you how to receive the codes, and then how to transmit them.

Objects required for this project:
1x Arduino (any kind as long as it has whats called "PWM" which I will explain)
1x IR LED (you can get these from any TV remote)
1x IR reciever (see picture)
1x USB A to B wire for programming the Arduino
1x Computer to program the Arduino with
1x Arduino software
and the .PDE files I will include

This website really helped me out a lot with this. http://www.ladyada.net/learn/sensors/ir.html

THIS IS NOT MY CODE, I DO NOT CLAIM OWNERSHIP. I merely copied and pasted the code and rewrote the instructions to make this easy to understand. 


Step 1: Preparing to Receive Signals

First you want to get the IR LED Receiver mentioned in the introduction.

You can get one here: http://www.adafruit.com/products/157
They cost $2 not including shipping and handling.

So you want to hook up the receiver according to the first picture.

I highly suggest putting both the IR Receiver and the remote in a shoe box or something that is dark (the same shoe  box of course). This will insure there will be the least amount of interference and to have clearer code so you don't have to program your Arduino 12 times for one simple task. Also, make sure you are out of the way of people watching TV.

And you want to download the file named IR_RECORD.PDE and open it into the Arduino program.

Plug your Arduino in with the USB cable I hope you have and proceed to step 2!
You can get the IR Receiver from just about any old VCR, TV, DVD player, anything that had a normal IR remote. I have a hand full of those sensors that I took from all the old broken devices i have laying around. Thanks for the tutorial.
You're welcome! Show this to your friends and see what they make!
<p>It didn't work for my air conditioner. I receive the code which is much longer than a typical TV remote but I cannot send it.</p>
<p>ACs have a very different set of protocols for communication. I have written an instructable just about that. You can check it out on my user page..</p>
<p>My arduino uno does not work anymore after uploading ir send sketch. It seems bootloader was override</p>
<p>Hello - do you think an Arduino could &quot;listen&quot; to VCR tv codes and trigger the TV accordingly ? my project idea is here : https://raffner.com/finally-an-ad-blocker-for-tv-ads-zapads/</p>
<p>Hello - do you think an Arduino could &quot;listen&quot; to VCR tv codes and trigger the TV accordingly ? my project idea is here : https://raffner.com/finally-an-ad-blocker-for-tv-ads-zapads/</p>
<p>This will work: http://arduino-info.wikispaces.com/IR-RemoteControl </p>
<p>This method does not work</p><p>try the method on this link</p><p>https://learn.adafruit.com/using-an-infrared-library/sending-ir-codes</p>
<p>That's great, thanks Wally. I'm making a TV remote floor rug for my friend who has cerebral palsy and has very limited movement. This is very helpfull. </p>
<p>hey there nice project i did every thing above but the ir remote numbers keep changing it does not stay the same is that a proplem from my ir reciver or it is from the ir remote </p><p>do i have to change the ir remote or what </p><p>thanks </p>
<p>hey there nice project i did every thing above but the ir remote numbers keep changing it does not stay the same is that a proplem from my ir reciver or it is from the ir remote </p><p>do i have to change the ir remote or what </p><p>thanks </p>
<p>It did not work for me. I was able to get the &quot;raw data&quot; but it does not work. I assume the code should be the same every time but instead I get different raw data when I press the same button. The code to send the raw data does not work I guess.</p>
<p>Hi there!</p><p><br>I went through this instructable but unfortunatelly, i couldn't manage to make it work.<br>I used an Arduino Mega instead of Uno. To be more specific:</p><p>-I connected the IRReceiver Out pin to Arduino Mega digital Pin 2 (and of course the other two as its shown the picture above).<br>-I downloaded the IR_RECIEVE.pde then I uploaded it to my Arduino Mega.<br>-I opened the Serial Monitor. It wrote &quot;Ready to decode IR!&quot;.<br>-I pushed the on/off button on my remote, but nothing happened in the Serial monitor.<br><br>Any guess what can be wrong?</p><p><br>Thank you in advance!</p>
<p>Same with me</p>
<p>I wrote a script in python to convert the output of the arduino into the delayMicroseconds en pulseIR code.<br>you have to rename 'path\filename.txt' in your own code. :)<br>Hopefully The code gets printed correct</p><p>file_object = open('path\filename.txt','r')<br>for f in file_object:</p><p>f = f.replace(&quot;usec&quot;,&quot;&quot;)<br>f = f.replace(&quot; ,&quot;,'')<br>f= f.split()<br>print (&quot;delayMicroseconds(&quot;+f[0]+&quot;);&quot;)<br>print(&quot;pulseIR(&quot;+f[1]+&quot;);&quot;)</p>
<p>I cannot download your files :(</p><p>Your also talking about IR_RECORD.PDE which is nowhere to find :S</p><p>What do I do wrong</p>
<p>IR_RECIEVE.PDE</p><p>/* Raw IR decoder sketch!</p><p> This sketch/program uses the Arduno and a PNA4602 to </p><p> decode IR received. This can be used to make a IR receiver</p><p> (by looking for a particular code)</p><p> or transmitter (by pulsing an IR LED at ~38KHz for the</p><p> durations detected </p><p> Code is public domain, check out <a href="http://www.ladyada.net" rel="nofollow"> www.ladyada.net </a> and adafruit.com</p><p> for more tutorials! </p><p> */</p><p>// We need to use the 'raw' pin reading methods</p><p>// because timing is very important here and the digitalRead()</p><p>// procedure is slower!</p><p>//uint8_t IRpin = 2;</p><p>// Digital pin #2 is the same as Pin D2 see</p><p>// <a href="http://arduino.cc/en/Hacking/PinMapping168" rel="nofollow"> http://arduino.cc/en/Hacking/PinMapping168 </a> for the 'raw' pin mapping</p><p>#define IRpin_PIN PIND</p><p>#define IRpin 2</p><p>// the maximum pulse we'll listen for - 65 milliseconds is a long time</p><p>#define MAXPULSE 65000</p><p>// what our timing resolution should be, larger is better</p><p>// as its more 'precise' - but too large and you wont get</p><p>// accurate timing</p><p>#define RESOLUTION 20 </p><p>// we will store up to 100 pulse pairs (this is -a lot-)</p><p>uint16_t pulses[100][2]; // pair is high and low pulse </p><p>uint8_t currentpulse = 0; // index for pulses we're storing</p><p>void setup(void) {</p><p> Serial.begin(9600);</p><p> Serial.println(&quot;Ready to decode IR!&quot;);</p><p>}</p><p>void loop(void) {</p><p> uint16_t highpulse, lowpulse; // temporary storage timing</p><p> highpulse = lowpulse = 0; // start out with no pulse length</p><p>// while (digitalRead(IRpin)) { // this is too slow!</p><p> while (IRpin_PIN &amp; (1 &lt;&lt; IRpin)) {</p><p> // pin is still HIGH</p><p> // count off another few microseconds</p><p> highpulse++;</p><p> delayMicroseconds(RESOLUTION);</p><p> // If the pulse is too long, we 'timed out' - either nothing</p><p> // was received or the code is finished, so print what</p><p> // we've grabbed so far, and then reset</p><p> if ((highpulse &gt;= MAXPULSE) &amp;&amp; (currentpulse != 0)) {</p><p> printpulses();</p><p> currentpulse=0;</p><p> return;</p><p> }</p><p> }</p><p> // we didn't time out so lets stash the reading</p><p> pulses[currentpulse][0] = highpulse;</p><p> // same as above</p><p> while (! (IRpin_PIN &amp; _BV(IRpin))) {</p><p> // pin is still LOW</p><p> lowpulse++;</p><p> delayMicroseconds(RESOLUTION);</p><p> if ((lowpulse &gt;= MAXPULSE) &amp;&amp; (currentpulse != 0)) {</p><p> printpulses();</p><p> currentpulse=0;</p><p> return;</p><p> }</p><p> }</p><p> pulses[currentpulse][1] = lowpulse;</p><p> // we read one high-low pulse successfully, continue!</p><p> currentpulse++;</p><p>}</p><p>void printpulses(void) {</p><p> Serial.println(&quot;\n\r\n\rReceived: \n\rOFF \tON&quot;);</p><p> for (uint8_t i = 0; i &lt; currentpulse; i++) {</p><p> Serial.print(pulses[i][0] * RESOLUTION, DEC);</p><p> Serial.print(&quot; usec, &quot;);</p><p> Serial.print(pulses[i][1] * RESOLUTION, DEC);</p><p> Serial.println(&quot; usec&quot;);</p><p> }</p><p>}</p>
<p>Pretty cool i made it to where you can go to the serial monitor and type a command like channel up or channel down and it will work accordingly</p>
<p>I lost the remote to my tv and I'm trying to make an arduino remote to replace it. Can I get the tv specific codes if I don't have the original remote? </p>
<p>here is a database of remote control codes for an old program called LIRC which could help you: http://lirc.sourceforge.net/remotes/</p>
<p>how to connect IR transmitter to arduino uno.... </p>
<p>hi can u give me a help?actualy, Im trying to send an code for a setup box, from an arduino uno, but even the exemplo in the sketch is not working, and im connecting the ir transmissor in pin -3 ... in my roject im trying to receive an code from a conroler and transmiting the same code to a setup box... all the things in my project works, until the transmissor shines when i look by a camera, but is not sending anything. i dont have idea what i can try anymore.</p>
<p>Hi everyone ,</p><p>I am working on ir transmission protocols . I did my ir system for samsung smart tv . I am curios on are there any command to shuw down the television (it is not matter television on which state (on,off))</p><p>thank you</p>
<p>Arduino: 1.6.6 Hourly Build 2015/07/21 05:42 (Windows 7), Board: &quot;Arduino Uno&quot;</p><p>D:\maitreya\Arduino\arduino-nightly\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>Error compiling.</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><p>what is the meaning of this?</p>
<p>You should really add a schematic for step 4. I don't know what value resistor to use with an Arduino UNO...</p>
<p>Never, ever, EVER copy and paste the same line (or 2 lines) of code multiple times in the same program. Any time you see that, big alarm bells should be going off in your head. What you want is a for loop that goes through an array of values. There are some really good beginning guides to programming out there if you're looking to get started.<br><br>Also, I believe the arduino library has a &quot;tone&quot; function which will auto-magically generate a square wave at a given frequency a little more robustly than what you have here.</p>
<p>i seem to get errors in ir_send code:</p><p>ir_send_test_2.ino: In function 'void SendChannelUpCode()':</p><p>ir_send_test_2.ino:199:11: error: too few arguments to function 'void pulseIR(long int)'</p><p>ir_send_test_2.ino:27:8: note: declared here</p><p>Error compiling.</p>
<p>Thanks for the code it works great. I'm using it on a TV which I use as an extra monitor for my computer.<br>I've added some code so when I turn on my PC (and the USB ports come on) it sends the &quot;power on&quot; signal and I also hooked up the on/off and change input (TV, HDMI, VGA, etc.) to two push buttons.<br><br>Any ideas how I could get the arduino to turn the TV off when the computer turns off just before the USB ports lose power?</p>
<p>how do i download the files</p>
<p>On the first page of the tutorial there are two files, you should be able to click on them to download them.</p><p>Or you could right click and &quot;open in new tab&quot; then copy and paste the text into the adruino software.</p>
<p>how do i download the files</p>
<p>no code is coming in at all</p>
<p>Hi. I am receiving 7 digit hexadecimal code when i press a button from a remote. What to do with it if i want to control with arduino?</p>
I did everything as detailed but my IR LED will not go off. I received the code from a sony camera remote. Got the usec lists and then put it onto the SEND sketch. But My IR LED swill not go off. I looked at it with the iphone camera and there is no light. I substituted it with an ordinary LED and it does ligth up. what am I doing wrong?
<p>i think we can't see IR rays through iphone camera..see through any other.For me it works</p>
<p>It has been a while, but it might be worth confirming that cameras usually have an infrared filter that dim or stop infrared rays.</p>
<p>Mine does the same thing; I'm not sure what's wrong.</p>
<p>Does not work with my Sony soundbar and I get new codes everytime I click on button.</p>
<p>With my Sansui TV remote I was reading the codes and I would get about 24 lines of code that repeated. but every time the first line was different. but it stayed within a range, 0 - 65000. So basically you call the function multiple times with different values. (in a FOR or WHILE loop) for me what worked was cycling up 0-65000 in increments of 1000 and then back down. If I just cycled through once going up the TV would turn on and then turn right back off. Which is why I needed both loops. Maybe this will help! :)</p>
<p>Would there be a way to, instead of repeating the signal, but to use it to say, turn on a motor or something?</p>
Meaning you send a signal over IR and you talk to another arduino that controls a motor or relay?<br><br>It's absolutely possible, you just have to figure out what signal you want to send.
<p>If you don't have an IR LED at hand you can use bright red LED. I tried it and it works!</p>
<p>Just did this. It worked very well. I am very impressed. Very good tutorial.</p>
<p>Hi, Can we just make the same with IR helicopter toy?</p>
<p><strong><em>THANK YOU! THANK YOU! THANK YOU!</em></strong> This is so much help i have been looking every where for exactly this and nowhere has it that works so when is saw this i thought i would give it one last try and it worked <strong><em>THANK YOU!</em></strong></p>
<p>how u upload this code it have errors check it...</p>
Worked like a charm... <br>This was fun, thank you.

About This Instructable




Bio: I like to tinker with electronics. I like to mod, hack, and learn how something works by taking it apart.
More by Wally_Z:Industrial-Grade GoPro Rollbar Mount Arduino Police Lights (ATMega 2650 Version) **New Flash Patterns!** How to control your TV with an Arduino! 
Add instructable to: