Arduino Infrared Remote Tutorial


634,478

277

139

Introduction: Arduino Infrared Remote Tutorial

I am a full time software engineer and enjoy working on various projects in my spare time, especial…

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/

12 People Made This Project!

Recommendations

  • Home and Garden Contest

    Home and Garden Contest
  • Stone Concrete Cement Contest

    Stone Concrete Cement Contest
  • Colors of the Rainbow Contest

    Colors of the Rainbow Contest

139 Comments

0
daviddog77898
daviddog77898

Question 3 years ago on Introduction

My controller instead of saying PWR GND or SIG

It says G,R,and Y

Any help with this

0
eogoneill
eogoneill

Answer 10 hours ago

G=Ground, R=Power and Y=Signal..

0
LuizR13
LuizR13

7 months ago on Step 3

such a lovable tutorial , worked like a charm many thanks !!!

my ir remote worked a little different so hero are mine :
Up arrow : FF629D
Left arrow : FF22DD
OK : FF02FD
Right arrow: FFC23D
Down arrow: FFA857
1 : FF6897
2 : FF9867
3 : FFB04F
4 : FF30CF
5 : FF18E7
6 : FF7A85
7 : FF10EF
8 : FF38C7
9 : FF5AA5
: FF42BD
0 : FF4AB5
# : FF52AD

again Thanks again.

0
lasanthaliyanawatta
lasanthaliyanawatta

Question 11 months ago

i did t get any numbers throw serial monitor

0
beast69
beast69

Question 1 year ago on Step 7

hi, i have tried the program "Arduino Infrared Remote Tutorial by astrodan3" but it does not work for me. I get a fairly long error message.
c:\users\owners\documents\arduino\testsketch\testsketch2.ino.ino: in function 'void loop()':
c:\users\owners\documents\arduino\testsketch\testsketch2.ino.ino:17:29: warning: 'bool irrecv:decode(decode_results')' is deprecated: without a parameter. [-Wdepracated-declarations].
It goes on after that. I am a real novice at this and need help anyone please.
Thank You
Robert
rneglia@cogeco.ca
0
godstimeobruche25
godstimeobruche25

1 year ago


CODE 2.
#include <IRremote.h>
const int RECV_PIN = 13;
IRrecv irrecv(RECV_PIN);
decode_results results;
void setup(){
Serial.begin(9600);
irrecv.enableIRIn();
irrecv.blink13(true);
}
void loop(){
if (irrecv.decode()){ // I removed the parameter &results
Serial.println(results.value, HEX); // Receive the next value in HEX. Like [FFFTTG]
irrecv.resume(); // Receive the next value
}
}

monitor failure 2.PNG
0
godstimeobruche25
godstimeobruche25

1 year ago

Pls, i want solution from someone here.
I was using compaq laptop window7 programming with Arduino successfully. I changed PC to HP which i'm coding with, but the Serial monitor in Arduino Ide is not reading real Remote button value. I installed(CH34x_Install_Windows_v3_4) (Arduino IDE 1.8.0, 1.8.1, 1.8.13.)
Below is code:

CODE 1.
#include <IRremote.h>
const int RECV_PIN = 13;
IRrecv irrecv(RECV_PIN);
decode_results results;
void setup(){
Serial.begin(9600);
irrecv.enableIRIn();
irrecv.blink13(true);
}
void loop(){
if (irrecv.decode(&results)){ // if (irrecv.decode())
Serial.println(results.value, HEX); // Receive the next value in HEX. Like [FFFTTG]
irrecv.resume(); // Receive the next value
}
}

monitor failure.PNG
0
SteCla
SteCla

3 years ago on Step 4

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

0
bbazeghi
bbazeghi

Reply 1 year ago

Yes, that is correct. i got answer with IRremote.h
another header file :IRemote.h canot be find from shiiriff!!

0
electronicsmith
electronicsmith

2 years 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/

0
Lime-Parallelogram
Lime-Parallelogram

Question 3 years 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 2 years ago

Did you double check the wires? Your code seems right

0
ricocamus
ricocamus

Question 3 years 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

4 years ago

I tried it and it worked in first attempt

thanks

0
ganeshbandi
ganeshbandi

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