Introduction: Finding the IR Codes of Any IR Remote Using Arduino
Most of the appliances from TV, DTH receiver , DVD Players to AC, etc are controlled wirelessly using IR remotes.
If you want to make an IR based project with a remote which you bought from the market or the remote of your AC, TV ,etc. then, you should be aware of the codes which are sent by the remote to the IR receiver in the appliance or device
We make several projects on various platforms and we always need the codes of any appliance, console, etc just by using an Arduino.
Step 1: THINGS USED IN THIS PROJECT
Hardware components:
- Arduino UNO
- IR receiver (generic)
- IR Remote (Anyone or the one which you want to use in your project)
Software apps and online services:
- Arduino IDE
Step 2: Working on Basics
IR remote has a button and a microcontroller with IR LED attached. When a button is pressed, a microcontroller identified the button and sends the corresponding modulated signals (codes) to the IR LED. Then, the IR LED sends it to the IR receiver in the appliance.
System in the appliance demodulate the signals(codes) and the checks the function corresponding to it and executes it. Each function has a different code.
Every IR operated appliance has different codes for different function.
We can't see the infrared(IR) light because their wavelength is not in our spectrum.
Step 3: Hookup
Follow the steps:
- Connect the first pin from left (OUT pin) with the pin 11 of Arduino.
- Hook the middle pin (GND pin) with the GND pin of the Arduino.
- Connect the third pin (VCC pin) with the 5 V pin of the Arduino.
Step 4: Code for Finding the IR Codes
Remember to install the IRremote library first
Click on download for .zip library file.
<p>#include <IRremote.h> //including infrared remote header file<br> int RECV_PIN = 11; // the pin where you connect the output pin of IR sensor IRrecv irrecv(RECV_PIN); decode_results results; void setup() { Serial.begin(9600); irrecv.enableIRIn(); } void loop() { if (irrecv.decode(&results)) { int value = results.value; Serial.println(" "); Serial.print("Code: "); Serial.println(results.value); //prints the value a a button press Serial.println(" "); irrecv.resume(); // Receive the next value Serial.println("*****************"); } }</p>
Step 5: Uploading and Testing
- Copy or download the code attached with the project.
- Hit upload and open serial monitor.
- Take any remote you want to use or you want the codes off it and press any button.
- Now, see in the serial monitor. You will see a code of the corresponding button you pressed.
- Note the codes on a paper or copy them in a document file on PC.
You can also run the online simulator for further understanding by clicking here.
13 Comments
Question 2 months ago
Is there any way to get the codes if I lose the controller, I only have available the receiver ( digital photo frame)
1 year ago on Step 2
If you aim your remote control to the camera of your phone you'll see the IR light ;-)
Reply 2 months ago
Yes remote signal is emmitted, but perhaps not received by the receiver.
Question 2 months ago
I am not getting the remote button codes on the screen of serial monitor. I am not sure, if the serial monitor has opened. Sketch is successfully uploaded, the I pressed the button on the top right corner, below is written "output" and "serial monitor" then one "x" is there. Is that the serial monitor? Below that written, "messages(enter to send message to arduino nano on com3". Am I at the right place? Now, when I click the buttons on remote, no code is displayed. Can anyone guide me?
2 years ago
I follow u on Hackster.io 2
2 years ago
Instead of this "scientific" limitation of IR remote control:
We can't see the infrared (IR) light because their wavelength is not in our spectrum
Human vision does NOT respond to IR (Infra Red) light : so it is invisible to us.
2 years ago
Thought this might be a more universal decoder than my own project but it gave completely wrong codes for my simple NEC remotes. Guess I'll have to dig into the library to see what it's doing.
2 years ago
Just what I need! Works perfectly!
3 years ago
Short, simple, & just what I was looking for. My kid lost the remote to the dvd player in our van, the dealer wants over $200 for a new one. If I can find one to borrow, now I can map all the codes.
3 years ago
Na primeira linha está faltando a biblioteca após #include
Reply 3 years ago
Hello, thanks for the comment. I have corrected the code above.
5 years ago
Wow
5 years ago
Great! I'll try this!