Introduction: Arduino Infrared Remote Tutorial
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
#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!
146 Comments
Question 5 months ago on Step 4
nothing is coming up on my serial monitor
Question 6 months ago on Step 4
exit status 1
'IRrecv' does not name a type
What does this mean and how do i fix it? please and thank you
Answer 5 months ago
Have you included the IRremote.h header file at the beginning of your code?
1 year 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.
Reply 8 months ago
What remote is this?
Reply 8 months ago
sorry for the delay was one of these xinda or keyes remote maybe these codes work for both did't find the link but here the pics
8 months ago on Step 2
I think the link expired, it says "error" every time I click it
Reply 8 months ago
try one of these
https://www.arduino.cc/reference/en/libraries/irre...
https://github.com/Arduino-IRremote/Arduino-IRremo...
Question 5 years ago on Introduction
My controller instead of saying PWR GND or SIG
It says G,R,and Y
Any help with this
Answer 1 year ago
G=Ground, R=Power and Y=Signal..
Question 2 years ago
i did t get any numbers throw serial monitor
Question 2 years ago on Step 7
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
2 years 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
}
}
2 years 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
}
}
4 years ago on Step 4
at the include statement... IRemote.h should be IRremote.h ?
Reply 2 years ago
Yes, that is correct. i got answer with IRremote.h
another header file :IRemote.h canot be find from shiiriff!!
3 years ago
Consider to use the Arduino IRMP library for receiving and sending. It suppports 50 different IR protocols.
3 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/
Question 4 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.
Answer 4 years ago
Did you double check the wires? Your code seems right