It is really easy to control an Arduino using an infrared remote. There is one particular remote that is available from multiple sources and is really quite cheap, they look and operate in a very similar way.

NEOMART Raspberry Pi HX1838 Infrared Remote Control Ir Receiver Module DIY Kit.  Amazon
Kootek Raspberry Pi Infrared Remote Control Ir Receiver Module DIY Kit. Amazon

The problem is that documentation seems to be scarce for these particular remotes. Here is how I figured out how to use them.

Step 1: Assemble Circuit

You will need one Arduino for this. I used a UNO, but just about any Arduino should work. First wire up the infrared receiver that came with your kit. There are 3 wires, PWR, GND, and SIG, I used port 11 for SIG. Note! some readers have reported that their sensor has different wiring, double check it yourself.

Step 2: Download IR Library

In order to reverse engineer the remote and obtain the codes for each button we are going to need to download and install the following library.


Extract the file in your libraries directory. e.g.  ( C:\electronics\arduino-1.0.5\libraries )
note: I had to rename the library because the name was too long, I just renamed it to IR.


Step 3: Add Library to Sketch

With the IR folder ( or whatever you named it) now in your libraries directory, we can import it into a new sketch.

Start a new sketch and the Click  

        Sketch->Import Library->IR.

Step 4: Paste Code and Compile

Paste the following code into the new sketch. Then verify it compiles.

#include <IRemote.h>
int RECV_PIN = 11;
IRrecv irrecv(RECV_PIN);
decode_results results;

void setup()
  irrecv.enableIRIn(); // Start the receiver

void loop()
  if (irrecv.decode(&results))
     Serial.println(results.value, HEX);
     irrecv.resume(); // Receive the next value


Step 5: Open the Serial Monitor

Connect the Arduino to your computer using the usb port, then upload the sketch. Open up the Serial Monitor, get the remote and press the buttons. Some hex codes should appear on the Serial Monitor.


Step 6: Record Button Codes

Here are the codes that I got for the white remote. FFFFFF is a repeat command, you'll get a stream of them if you hold down a button.

PWR       FF629D     
CH          FFE21D        
|<<          FF22DD  
>|            FFC23D              
>>|          FF02FD               
-              FFE01F 
Plus        FFA857         
EQ          FF906F          
0             FF6897            
100         FF9867           
200         FFB04F           
1             FF30CF                 
2             FF18E7                 
3             FF7A85                  
4             FF10EF                   
5             FF38C7                    
6             FF5AA5                  
7             FF42BD                  
8             FF48B5             
9             FF52AD 

and here are the codes I got from the black remote.

PWR                               FD00FF
VOL                                FD807F
FUNC/STOP                    FD40BF
|<<                                   FD20DF
>|                                     FDA05F
>>|                                   FD609F
DOWN                             FD10EF
VOL                                 FD906F
UP                                   FD50AF
0                                      FD30CF
EQ                                   FDB04F
ST/REPT                         FD708F
1                                      FD08F7
2                                      FD8877
3                                      FD48B7
4                                      FD28D7
5                                      FDA857
6                                      FD6897
7                                      FD18E7
8                                      FD9867
9                                      FD58A7       

Step 7: Works on Any Remote!

Now go grab a bunch or remotes from around the house, and give those a try! I got a direct-tv remote and the smartphone pod/remote for a Helo TC remote controlled helicopter. This circuit showed the code for both of these remotes.

Here is the project that inspired me to write this up!


<p>hi there... i need 2 noe.. is there any way we can send or display temperature from the temp sensor in arduino at the lcd of a ir remote control which also has ir receiver ... can v send commands for the remote to display some info collected by arduino??? USING IR ONLY !!</p>
<p>Wow great tutorial.</p><p>I have one question, do somebody know how it's possible that i get only numbers, like 808, 26, 7 and i dont get hex codes.</p>
<p>In the Serial.println bit of code, just take away &quot;HEX.&quot;</p>
<p>OK I have got this remote and it is the king of weird codes. Heres what I get when a press the power button and hold it for sometime-</p><p>C722B335</p><p>8651F175</p><p>D440F4BA</p><p>673D41A</p><p>D440F4BA</p><p>673D41A</p><p>C722B335</p><p>673D41A</p><p>C722B335</p><p>673D41A</p><p>D440F4BA</p><p>673D41A</p><p>C722B335</p><p>673D41A</p><p>Heres what i get when I press it shortly so that i get only one reading per press-</p><p>D440F4BA</p><p>EDB7BF84</p><p>C722B335</p><p>7B33B312</p><p>C722B335</p><p>EDB7BF84</p><p>D440F4BA</p><p>EDB7BF84</p><p>C722B335</p><p>8651F175</p><p>C722B335</p><p>EDB7BF84</p><p>D440F4BA</p><p>EDB7BF84</p><p>C722B335</p><p>EDB7BF84</p><p>C722B335</p><p>F8D5FDE7</p><p>D440F4BA</p><p>EDB7BF84</p><p>I have previously cloned Sony, Samsung and LG remotes, but this DTH remote is a b**ch. The company isn't international and I live in India, so I can't find a module for it. Any help would be welcome.</p><p>Thanks</p>
<p>YES. I also at times get these codes. I dont understand WHY. sometimes i get correct code and sometimes I get these codes. Such an un-reliable remote.</p>
<p>I know why... I did some experimenting and I realised that you have to point the remote at a close range, and it also has to be level - I mean, at the same position. It gives the same result if you press the button at the same position.</p>
<p>I was also having this issue, I however realised it was because of the batteries in the remote were dying. Swapped them for new ones and they now detect a steady hex!</p>
<p>Don't want to resurrect a dead horse and then beat him - this post is a bit old.</p><p>But my ten cents....</p><p>.....is that maybe the codes ARE actually the same on each press, but perhaps the arduino gets lost in the the bits and doesn't catch where start and end is. Especially if you're holding the button down, then it just gets a really long set of pulses and doesn't know whats going on....whereas the TV or aircon knows what to look for among the mess...</p><p>Aircon to self:&quot;oh look! A power on/off command! That must be it! What are the chances of it being something else...?&quot;</p><p>Arduino:&quot;..............................ugh...........................oh man................wha?..........................................gaaaaaaaaaa! TMI! TMI! TMI! It doesn't make any sense! Why are you doing this to me!?&quot;</p><p>Among the frequency of pulsing, start bits, stop bits, and length of the train of pulses that is a single signal, maybe it just is too much for it sometimes.</p><p>So what I mean is, it might not be as bad as you think. Maybe code can fix it, or maybe some cheap logic analyzer can help you see what's going on.</p>
<p>Thank you so much! This helped greatly! #Set4Lyfe</p>
<p>Hey guys,</p><p>I'm relatively new to arduino, and keep getting this error code with this program.</p><p>avrdude: ser_open(): can't open device &quot;\\.\COM4&quot;: The system cannot find the file specified.</p><p>Problem uploading to board. See <a href="http://www.arduino.cc/en/Guide/Troubleshooting#upload" rel="nofollow"> http://www.arduino.cc/en/Guide/Troubleshooting#up...</a> for suggestions.</p><p>Anyone help?</p>
<p>just click on tools, then under com it should say the port its conected to, click on it and compile again</p>
<p>I found it out.</p><p>I just forgot to choose the port to hook up the arduino.</p>
<p>Hello, I found the solution for compiling errors!</p><p>1.) You must download this folder:</p><p><a href="https://github.com/z3t0/Arduino-IRremote" rel="nofollow">https://github.com/z3t0/Arduino-IRremote</a></p><p>2.) Place folder in C:\Program Files (x86)\Arduino\libraries</p><p>3.) Rename it to &quot;IRremote&quot;</p><p>4.) Delete &quot;RobotIRremote&quot; folder.</p><p>5.) There is error in code at very top #include &lt;IRemote.h&gt; --&gt;r is missing,</p><p>put in: #include &lt;IRremote.h&gt;<br></p><p>I managed it to work that way. Hope you will too! cheers</p>
<p>It's work fine!</p>
<p>SORRY, IT DOESNT WORK!!! It Says the sketch has errors when i compile it...</p>
<p>Watch out, some IR receivers have the OUT on pin#1.</p><p>How can I clear the input buffer for the next IR read?</p>
<p>How can i read IR receiver output on Arduino mega</p>
<p>the code just wont compile!</p><p>Arduino: 1.6.13 (Windows 10), Board: &quot;Arduino/Genuino Uno&quot;</p><p>In file included from C:\Users\...\Documents\Arduino\recieverCode\recieverCode.ino:4:0:</p><p>C:\Users\...\Documents\Arduino\libraries\Arduino-IRremote-master/ir_Lego_PF_BitStreamEncoder.h: In member function 'int LegoPfBitStreamEncoder::getRepeatStopPause() const':</p><p>C:\Users\...\Documents\Arduino\libraries\Arduino-IRremote-master/ir_Lego_PF_BitStreamEncoder.h:107:38: warning: integer overflow in expression [-Woverflow]</p><p>return STOP_PAUSE_DURATION + 5 * MAX_MESSAGE_LENGTH - messageLength;</p><p>^</p><p>This application has requested the Runtime to terminate it in an unusual way.</p><p>Please contact the application's support team for more information.</p><p>Cannot create temporary file in C:\Users\...\AppData\Local\Temp\: Permission denied</p><p>exit status 3</p><p>Error compiling for board Arduino/Genuino Uno.</p><p>This report would have more information with</p><p>&quot;Show verbose output during compilation&quot;</p><p>option enabled in File -&gt; Preferences.</p>
<p>The sketch won't compile:</p><p>It gets the following errors:</p><p>sketch_jul31b:3: error: 'IRrecv' does not name a type</p><p>sketch_jul31b:4: error: 'decode_results' does not name a type</p><p>sketch_jul31b.ino: In function 'void setup()':</p><p>sketch_jul31b:9: error: 'irrecv' was not declared in this scope</p><p>sketch_jul31b.ino: In function 'void loop()':</p><p>sketch_jul31b:14: error: 'irrecv' was not declared in this scope</p><p>sketch_jul31b:14: error: 'results' was not declared in this scope</p><p>The code:</p><p>#include &lt;IRemote.h&gt;</p><pre>int RECV_PIN = 11;<br>IRrecv irrecv(RECV_PIN);<br>decode_results results;<br><br>void <strong>setup</strong>()<br>{<br><strong> Serial</strong>.begin(9600);<br> irrecv.enableIRIn(); // Start the receiver<br>}<br><br>void <strong>loop</strong>()<br>{<br> if (irrecv.decode(&amp;results))<br> {<br><strong> Serial</strong>.println(results.value, HEX);<br> irrecv.resume(); // Receive the next value<br> }<br>}</pre>
<p>do you have the library installed for it and included for the IR receiver at the top of the code?</p>
<p>if the IRremote is used these errors don't appear. If IRemote is used the above errors appear</p>
<p>c:/program files (x86)/arduino/hardware/tools/avr/bin/../lib/gcc/avr/4.3.2/../../../../avr/bin/ld.exe: sketch_sep04a.cpp.elf section .text will not fit in region text</p><p>c:/program files (x86)/arduino/hardware/tools/avr/bin/../lib/gcc/avr/4.3.2/../../../../avr/bin/ld.exe: region text overflowed by 722 bytes</p><p>I got am error like this? what can i do? how i solve this? my board is arduino with atmega8 (FREEDUINO)</p>
<p>Hi @thunderboympm</p><p>You made mistake in writing the header file,</p><p>If you see your attached image, you have written &quot;#include&lt;IRremote.h&gt;&quot;</p><p>Correct it by writing; &quot;#include&lt;IRemote.h&gt;</p><p>Happy :-)</p>
<p>What can I do if i want to Compare two IR received Strings ??? </p>
<p>Didn't get anything on the serial monitor... Then i realized i had forgotten to change the pin you read on. Haha!</p>
<p>Great tutorial! I broke apart a small IR Helicopter toy I had around. I used its IR sensor for this tutorial. What's strange, is the IR Sensor won't detect any signal from it's original remote, but it reads signals from any other TV remotes I got hanging around.</p><p>Anyone has any clue what I can be missing?</p><p>The Remote has 3 &quot;chanels&quot; or 3 comm protocols so that you can fly up to 3 of these things without the signals interfering, but the IR sensor won't pick up any kind of signal whatsoever!</p><p>Cheers again for this great piece of info!</p>
<p>IR remote does not display in the serial monitor IRreceive I think I uploaded the code that nothing is wrong as well, but when I stick my hand into IRreceiver monitor displays the serial code ..</p>
<p>Hi I need to resolve is there who can help me</p><p>Thank you</p>
<p>delete the robort ir library its creating the problem</p>
<p>you have open arduino librarys in your case, E:\arduino-nightly\libraries and delete this library (RobotIRremote). close arduino and open again &amp; Ready :) </p>
<p>Works like a charm(and yes, it's not connected atm)</p>
<p>Nice and easy, works also with my Android phone as a remote!!</p>
<p>I'm getting a compiling error: 'TKD2 was not declared in this scope'. Anyone know how to fix this? Thanks</p>
<p>How did you solve that problem, because I encounter this</p><p>Thanks</p>
<p>Nice Abstract. </p>
Thanks a lot.... I have been breaking my head to understand IR buttons coding. Helped a lot.
<p>Mine too. This guy is so bad, he should atleast have decency to update his tutorial and mention about it. I fried mine also.</p>
<p>How can you take this and make it do something when you press a button. Such as Print a line or run a motor?</p>
<p>Yes I have programmed it to receive code from a Sony remote and move a servo</p>
Can you post that if pressed code?
Do you have a program to connect motors to arduino and control them using IR remote?
<p>my code for one led and remote control of MP3 player.</p>
<p>#include &lt;IRremote.h&gt; // libraria IR control remoto.</p><p>int RECV_PIN = 11;// pin donde recibiremos la se&ntilde;al</p><p>#define ON 0xFFA25D // direccion es FFA25D pero se le agrega el 0x </p><p>// porque asi se le dice al arduino que es HEXADECIMAL.</p><p>#define OFF 0xFF629D // tecla control stop</p><p>unsigned int led = 13;</p><p>boolean estado = false;</p><p>IRrecv irrecv(RECV_PIN); //</p><p>decode_results results;</p><p>// aca guardamos el dato que nos del el IR</p><p>void setup()</p><p>{</p><p> //Serial.begin(9600);</p><p> irrecv.enableIRIn(); // Inicia el IR in</p><p> pinMode(led,OUTPUT); // configuramos el led como salida</p><p>}</p><p>void loop() {</p><p> // si el IR recibe una se&ntilde;al se habilita la funcion.</p><p> if (irrecv.decode(&amp;results)) {</p><p>switch (results.value)</p><p>// si el resultado obtenido esta en el case se ejecuta</p><p>{</p><p> case ON:</p><p> // en el caso que sea la direccion 0xFFA25D</p><p> // se ejecuta lo siguient</p><p> if (estado ? false : true){</p><p> // si es estado del es false se ejecuta</p><p> // y se asigna al estado true. </p><p> estado = true;</p><p> digitalWrite(led,estado);</p><p> }else </p><p> {</p><p> //sino se le asigna false nuevamente para que el led</p><p> // permanezca apagado</p><p> estado = false;</p><p> digitalWrite(led,estado);</p><p> }</p><p> break;</p><p>}</p><p>delay(200); // 1/5 second delay for arbitrary clicks. Will implement debounce later.</p><p>irrecv.resume(); // Receive the next value</p><p> }</p><p>}</p>
<p>Will any IRreceiver work with any remote? OR do I need a specific one? I've been trying to do this project, however my receiver and my remote don't seem to be working. Is there a way that my project could have failed?</p>
<p>work with any Remote control I tested the skecth but I have to delete de RobotIRemote (included as default ) <br>this is my code:<br>apagar = FFA25D</p><p>stop = FF629D</p><p>mute = FFE21D</p><p>mode = FF22DD</p><p>back-row = FF02FD</p><p>EQ = FFC23D</p><p>back = FFE01F</p><p>adelante = FFA857</p><p>play/stop = FF906F</p><p>vol+ = FF6897</p><p>vol- = FF9867</p><p>Numero 0 = FFB04F</p><p>Numero 1 = FF30CF</p><p>Numero 2 = FF18E7</p><p>Numero 3 = FF7A85</p><p>Numero 4 = FF10EF</p><p>Numero 5 = FF38C7</p><p>Numero 6 = FF5AA5</p><p>Numero 7 = FF42BD</p><p>Numero 8 = FF4AB5</p><p>Numero 9 = FF52A</p>
<p>Nope! As long as it is using the standard infrared remote wavelength (television, stereo, anything else pretty much), your Arduino should pick it up.</p>
<p>i am getting error while compiling the code, can anyone help me </p>
<p>It says &quot;#include &lt;IRemote.h&gt; but the &quot;r&quot; of &quot;remote&quot; is missing.</p><p>it must be: #include &lt;IRremote.h&gt;</p>
My IR receiver is dead : The +5V pin was on the right and the GND pin was in the middle...

About This Instructable




Bio: I am a full time software engineer and enjoy working on various projects in my spare time, especially Arduino, electronics, 3D printing and woodworking.
More by astrodan3:Arduino 6 wire Stepper Motor Tutorial  how to make vermicompost Arduino Infrared Remote tutorial 
Add instructable to: