Arduino Infrared Remote Tutorial




Posted in TechnologyElectronics

Introduction: Arduino Infrared Remote Tutorial

About: I am a full time software engineer and enjoy working on various projects in my spare time, especially Arduino, electronics, 3D printing and woodworking.

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!

9 People Made This Project!


  • Spotless Contest

    Spotless Contest
  • Microcontroller Contest

    Microcontroller Contest
  • Space Challenge

    Space Challenge

We have a be nice policy.
Please be positive and constructive.


5 Questions

Hi i tried this project bur I'm getting error messages about undeclared types any haelp would be appreciated, thanks

heres the error code

Arduino: 1.8.5 (Mac OS X), Board: "Arduino/Genuino Uno"

IR_receiver_test:2: error: 'IRrecv' does not name a type

IRrecv irrecv(RECV_PIN);


IR_receiver_test:3: error: 'decode_results' does not name a type

decode_results results;


/Users/kilian/Documents/Arduino/IR_receiver_test/IR_receiver_test.ino: In function 'void setup()':

IR_receiver_test:8: error: 'irrecv' was not declared in this scope

irrecv.enableIRIn(); // Start the receiver


/Users/kilian/Documents/Arduino/IR_receiver_test/IR_receiver_test.ino: In function 'void loop()':

IR_receiver_test:13: error: 'irrecv' was not declared in this scope

if (irrecv.decode(&results))


IR_receiver_test:13: error: 'results' was not declared in this scope

if (irrecv.decode(&results))


exit status 1

'IRrecv' does not name a type

This report would have more information with

"Show verbose output during compilation"

option enabled in File -> Preferences.



what does this error mean why i dont see anyting on the serial Monitor

the hole error is this

C:\Users\Daan\Desktop\sketch_mar11b\sketch_mar11b.ino:9:23: fatal error: IRemote.h: No such file or directory

#include <IRemote.h>


compilation terminated.

exit status 1
Fout bij het compileren van board Arduino/Genuino Uno



what does this error mean



now i get this error

dit i need to conect my arduino board


hello i'm sorry but I do not see the whole mistake for screenhot

1 more answer

did you add the IRremote library from Arduino IDE? checked please

I do not see the whole mistake



i got this error ,what in neet to do?

2018-03-13 (1).png

HELLO! you forgot: #include <IRremote.h>

there is an error in the tutorial "<IRemote.h>" instead of "<IRremote.h>"



i got the hexa codes in my remote but how can i send the codes to the consumer products please help me


Some pictures have only the sensor attached to the protoboard and then to the Arduino. Others have the sensor attached to that little module. Got confused with this also while looking to buy the components. Is that any difference? If so, what is the difference?

I tried it and it worked in first attempt


Worked nicely for me, thank you.

gets a bit dicey if you are too far away but that is a problem with hardware not software.

Simple to use and effective!

I've found this to be extraordinarily unreliable at anything less than six inches making it unusable for my application. The electronics work, just the work necessary to count leading and trailing clock edges with precision, coupled with the hash concept (so there's always a reduction of precision) makes it unpredictable. It uses lots of cycles which would be better off offloaded to another chip with better signal processing.

I'm sure each remote has it's own bias which is why there're different profiles with different timings for various manufacturers. Apparently the manufacturers are able to decode their signals though as most remotes I've used work well.

This is an ideal problem for an AI engine. Lots of unpredictability within the time domain yet only certain answers are feasible. While Ken Shirriff's code is all we have and to be applauded, it's not workable for most applications. An AI chip and the learning database wouldn't be cheap either but you get what you pay for, as usual.

The sketch won't compile:

It gets the following errors:

sketch_jul31b:3: error: 'IRrecv' does not name a type

sketch_jul31b:4: error: 'decode_results' does not name a type

sketch_jul31b.ino: In function 'void setup()':

sketch_jul31b:9: error: 'irrecv' was not declared in this scope

sketch_jul31b.ino: In function 'void loop()':

sketch_jul31b:14: error: 'irrecv' was not declared in this scope

sketch_jul31b:14: error: 'results' was not declared in this scope

The code:

#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
4 replies

this program is not uploading on my board

do you have the library installed for it and included for the IR receiver at the top of the code?

if the IRremote is used these errors don't appear. If IRemote is used the above errors appear

can anybody help me ??

my board is not taking this programe

Thank you so much, it worked for my TV remote. I have the CAR MP3 remote. It was pretty hard to get out the battery holder. I fed it a 3V Energizer CR2032 battery and I could barely close it's door. Now it won't function? How do you feed this remote/what battery do you use?


all i'm getting is FFFFFFFF

it doesn't change when i press other buttons

i don't know what the problem is

help plz

I found this error plz help :

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

int RECV_PIN = TKD2; // the pin the IR receiver is connected to


Multiple libraries were found for "IRremote.h"

Used: C:\Program Files (x86)\Arduino\libraries\RobotIRremote

Not used: C:\Users\umer\Documents\Arduino\libraries\Arduino-IRremote-master

exit status 1

Error compiling for board Arduino Nano.

1 reply

Delete your folder RobotIRremote in arduino libraries.

then don't forget to include <IRemote.h> in your code. or go to Sketch > include library > add .ZIP library >> and choose your zip file of IR library that you've downloaded

I'm getting a compiling error: 'TKD2 was not declared in this scope'. Anyone know how to fix this? Thanks

2 replies

Don't forget to include <IRemote.h>


Sketch > include library > IR

How did you solve that problem, because I encounter this


In my case, using HEX to return the values from the remote always caused an error. If the same ever happens to anyone reading this, use OCT or DEC instead of HEX. These return values containing only digits, but are almost equally useful :)

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