Arduino Infrared Remote Tutorial

577,056

264

132

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
KIT,IR REMOTE,IR RECIVER,ARDUI,COMPATIBLE  Jameco

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.

https://github.com/shirriff/Arduino-IRremote

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()
{
  Serial.begin(9600);
  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!

http://2manyprojects.net/arduino-remote-control/

11 People Made This Project!

Recommendations

  • Puzzles Speed Challenge

    Puzzles Speed Challenge
  • "Can't Touch This" Family Contest

    "Can't Touch This" Family Contest
  • CNC Contest 2020

    CNC Contest 2020

132 Discussions

0
electronicsmith
electronicsmith

5 months ago

ir is one of best short range communication method
i also have an article where you can build your own ir module
https://www.instructables.com/id/Long-Range-IR-Pro...
But the problem is the circuit is very complex to solder then if you want multiple modules for project like Line following robot.
So I have ordered the PCB from NextPCB when I receive the package I don't have high exceptions about it but I got surprised by the high quality. I highly recommend if you are beginner then order your PCB from NextPCB only.
I am leaving a link you can check it https://www.nextpcb.com/

1
Lime-Parallelogram
Lime-Parallelogram

Question 1 year ago

Hi, when I run this code, I receive no errors however information does not appear on the serial monitor. I am sure data is being received by the receiver since my LED is flashing just nothing on the arduino. Please see attached picture of my circuit and code. Any help would be greatly appreciated. Thanks.

Note: I have already tested multipul remotes to no avail.

SAM_6982.JPGScreenshot from 2019-03-04 17-58-39.png
0
iagows
iagows

Answer 1 year ago

Did you double check the wires? Your code seems right

2
SteCla
SteCla

1 year ago on Step 4

at the include statement... IRemote.h should be IRremote.h ?

0
ricocamus
ricocamus

Question 1 year ago

Is there a source for codes for different brands of remotes? My situation is the remote I have stopped working so I can't use it to send the codes and capture it with the Arduino.

0
DevinderS5
DevinderS5

2 years ago

I tried it and it worked in first attempt

thanks

0
daviddog77898
daviddog77898

Question 1 year ago on Introduction

My controller instead of saying PWR GND or SIG

It says G,R,and Y

Any help with this

0
ganeshbandi
ganeshbandi

2 years ago

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

thanks

0
D OP
D OP

Question 2 years ago on Step 5

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.

0
DaanB12
DaanB12

Question 2 years ago

Hello?


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

2018-03-20.png20180320_185435.jpg
0
DaanB12
DaanB12

Question 2 years ago

what does this error mean

2018-03-18.png
0
DaanB12
DaanB12

Question 2 years ago

now i get this error

dit i need to conect my arduino board

2018-03-15.png
0
OptimBoy
OptimBoy

Answer 2 years ago

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

0
OptimBoy
OptimBoy

Answer 2 years ago

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

I do not see the whole mistake

help1.pnghelp2.JPG
0
DaanB12
DaanB12

Question 2 years ago

i got this error ,what in neet to do?

2018-03-13 (1).png
0
OptimBoy
OptimBoy

Answer 2 years ago

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

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

help.png
0
SathR
SathR

2 years ago

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?