To use the universal remote, simply point your remote control at the IR module and press a button on the remote control. Then press the Arduino button whenever you want to retransmit the code. My example only supports a single code at a time, but can be easily extended to support multiple codes.
The hardware
The above picture shows the 9V battery pack, the Arduino board, and the proto board with (top-to-bottom) the IR LED, IR receiver, and pushbutton.
The circuitry is simple: an IR sensor module is connected to pin 11 to record the code, an IR LED is connected to pin 3 to transmit the code, and a control button is connected to pin 12. (My IR library article has details on the sensor and LED if you need them.)
The software
The code can be downloaded as part of my IRremote library download; it is the IRrecord example.
Handling different protocols
The code supports multiple IR protocols, each with its own slight complications:Sony codes can be recorded and played back directly. The button must be held down long enough to transmit a couple times, as Sony devices typically require more than one transmission.
The common NEC protocol is complicated by its "repeat code". If you hold down a button, the remote transmits the code once followed by multiple transmissions of special repeat code. The universal remote records the code, not the repeat code. On playback, it transmits the code once, followed by the repeat code.
The RC5 and RC6 protocols handle repeated transmissions differently. They use two separate codes for each function, differing in a "toggle bit". The first time you hold down a button, the first code is transmitted repeatedly. The next time you hold down a button, the second code is transmitted repeatedly. Subsequent presses continue to alternate. The universal remote code flips the toggle bit each time it transmits.
The universal remote handles any other unknown protocol as a "raw" sequence of modulated IR on and off. The main complication is that IR sensor modules typically stretch out the length of the "on time" by ~100us, and shorten the "off time" correspondingly. The code compensates for this.
Most likely there are some codes that that can't handle, but it has worked with the remotes I've tried.
The code also prints debugging information to the serial console, which can be helpful for debugging any problems.
In conclusion, this is intended as a proof of concept rather than a useful product. The main limitation is supporting one code at a time, but it's straightforward to extend the code. Also note that the record and playback functions can be separated; if you know the IR codes you're dealing with, you can use just the necessary function.

39 comments:
Very interesting - now if I just had a use for it, it would also be usefull.
I found a use for it, thanks for the library!
http://electrosthetics.blogspot.com/2009/11/arduino-universal-remote-and-more.html
I am using a JVC remote from what I can tell its like a NEC in alot of aspects. But I don't understand where to put in the numbers to decode in IRremote to add JVC as a type.
Thank you for the library. Very easy to use.
I'll be using it to trigger an Olympus camera based on a flying insect.
I can also see a lot of uses in a home automation setup.
The code works very well, however I cannot seem to get it to store and repeat more than one! Do you have any example code for this?
This started to work for me after increasing RAWBUF in IRremote.h to 256. Indeed, 129 bytes were collected from the non-standard remote of my aircondition. Maybe the default buffer is a bit tight here.
To the poster who wonders how to replay what's been received: Copy the received code sequence from the serial terminal, remove the s and m characters and pass the numbers to the sendRaw call.
My proof-of-concept sketch is here: http://pastebin.com/EzNNrYey
Thanks Ken for the great library!
This is one of the easiest thing to check for so you might as well be up front and honest.
I am a noob to Arduino so learning this is a bit difficult so please forgive me. I am trying to control a Tascam DR-100 any ideas where I should start. The DR-100 is controllable by IR and they have a little converter that will make the IR Remote wired but I figured that maybe start with the IR thing then try to get the wired working since it must be the same codes. What I want to do is to have an RTC in arduino start the DR-100 recording at a specific time then stop. There is no sleep in the DR-100 so no need to wake it up. Any clues?
Thanks
I'm doing all this reading and investigation because I've lost the remote for an old receiver & pre-amp and am hoping to get this to work in place of the missing remotes. I've found the proper pronto hex codes on remote-central but i'm still not quite sure how to take the pronto hex info from remote central and get it to be used in the arduino? I guess the part that is confusing to me is that there seems to be so many different modulation frequencies and i'm not sure how or even if that matters? any help would be greatly appreciated.
I am using the Library to control Channel master box....
Here are the commands:
#define cmUP 0x35CA8877
#define cmDOWN 0x35CA08F7
#define cmPOWER 0x35CA38C7
#define cmKEY0 0x35CA00FF
#define cmKEY1 0x35CA807F
#define cmKEY2 0x35CA40BF
#define cmKEY3 0x35CAC03F
#define cmKEY4 0x35CA20DF
#define cmKEY5 0x35CAA05F
#define cmKEY6 0x35CA609F
#define cmKEY7 0x35CAE01F
#define cmKEY8 0x35CA10EF
#define cmKEY9 0x35CA906F
Can someone give me some guidance please?
Am trying to make an Arduino based, dedicated "Closed Caption (CC) toggler".
In order to Toggle the CC, my set-top box's native remote requires eight (yes, eight) keystrokes.
This remote is not RC5. RC6, Sony or NEC.
Have built Arduino send/capture device and have captured RAW data from the set-top box's remote.
Problem:
Have attempted to use "IRrecord" to retransmit codes using Arduino apparatus described in the blog.
CAN do this with RC5 codes, thus demonstrating that hardware works properly.
HOWEVER: not able to do it with the set-top box remote that I actually need to use.
Can anyone direct me to a solution for this problem please?
To summarize:
1. Hardware has been built and tested for RC5
2. Have captured codes from remote, which I wish to retransmit from Arduino driven IR LED.
3. How do I send a sequence of eight sets of RAW to the IR LED and have it be readable by my set-top box.
Thank you for your help with this.
BobW
PS: Have successfully built Ken's Arduino TV-Begone.
BobW: See my comment above from April 9 on how I replayed the received raw codes. Still works for me.
Thank you Martin.
Will get to work on this tomorrow.
BobW
Martin:
I'm up and running thanks to your advice. Thanks so much for your help !
BobW
I have no success with this. Trying to use it with a Creative DDTS-100. I've used values from http://lirc.sourceforge.net/remotes/creative/DDTS-100 and changed IrremoteInt.h like this:
// pulse parameters in usec
#define NEC_HDR_MARK 8973
#define NEC_HDR_SPACE 4760
#define NEC_BIT_MARK 591
#define NEC_ONE_SPACE 1675
#define NEC_ZERO_SPACE 567
#define NEC_RPT_SPACE 2308
I then use IRsendDemo and change the send command:
irsend.sendNEC(0x15EA, 16);
The DDTS doesn't react. I see the IR-beam in my digital camera and have placed the transmitter Led really close to the DDTS.
I used the library to control some costumes in a play. Three characters had LEDs, a 9volt battery,an Ardweeny and a IR receiver. Using a Sony TV remote I was able to send codes to all three costumes simulaneously.
Worked great!
I found the error! Yes!! The answer is in this comment: "Hi reconnnn: I'm in the process of writing an explanation of LIRC data, but for your case LG usually uses 32-bit NEC protocol. Take the pre_data bytes in the LIRC file and join them to the bytes for the button you want to control to make a 4-byte hex number, and use sendNEC. Power on is probably 0x20df10ef; some LG devices use 0x897641be or 0x34347887. If you have an IR detector, you can read out what your remote sends, rather than looking in the LIRC files.
September 26, 2009 3:17 PM " from http://www.arcfn.com/2009/08/multi-protocol-infrared-remote-library.html.
If I use "irsend.sendNEC(0x8322E11E, 32);" the device turns on. Happy, now I can use the DDTS altough the remote went missing.
I've wrote down the process to use a Lirc file with Irremote: http://www.patrikhermansson.se/?q=node/430
Thanks for the great library! Unfortunately IRremote has
side effects on the build-in tone() library. Either sounds are
crippled or - after playing a tone - the receive library stops
working and returns 0 for any IR event.
Is there a way to fix this problem?
Or a workaround?
After a bit of searching and experimenting I stumbled upon this side: http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1176970454.
So the solution to the tune() imcompatibility is simply this code:
void freqout(int freq, int t)
{
int hperiod; //calculate 1/2 period in us
long cycles, i;
hperiod = (500000 / freq) - 7; // subtract 7 us to make up for digitalWrite overhead - determined empirically
// calculate cycles
cycles = ((long)freq * (long)t) / 1000; // calculate cycles
/* Serial.print(freq);
Serial.print((char)9); // ascii 9 is tab - you have to coerce it to a char to work
Serial.print(hperiod);
Serial.print((char)9);
Serial.println(cycles); */
for (i=0; i<= cycles; i++){ // play note for t ms
digitalWrite(outpin, HIGH);
delayMicroseconds(hperiod);
digitalWrite(outpin, LOW);
delayMicroseconds(hperiod - 1); // - 1 to make up for fractional microsecond in digitaWrite overhead
}
}
It works like charm with IRremote...
I'm trying to run this with a 56KBaud signal (TSOP1156 Receiver) but getting nowhere. As I'm new to Arduino can somebody tell me if I need to change anything anywhere please?
I have no idea of the signal format as it's not a domestic equipment remote that I'm trying to 'grab' and emulate - all I know is that the original equipment uses a TSOP1156 and (according to the info sheet) "The address is encoded into the IR sequence with 5 hamming code bits
and then manchester encoded to give a 32 bit complete code. Since manchester encoded then every transmitter sends 16 high and 16 low pulses. Giving an equal power on the beam. any erroroneous data is ignored by a recevier."
Tham eans absolutely nothing to me bot hopefully it may do to somebody...
Any assistance would be very welcome.
I have this working now (a well known make of prototyping board with a power rail that didn't run the full length!!!) but...
According to my camera phone, the IR LED stays on after the code has been sent - making for short battery life.
Has anyone else noticed this? Anyone have a fix?
It's using RAW, I don't know if that means anything in relation to the problem.
Thanks
Ken, this library is awesome, thanks a bunch. Anyway, I was playing around with sending multiple codes with a single button press. I have one button to turn on the TV and the AV receiver, another button that selects the audio mode on the receiver, etc. This library is so powerful that with macros you can build a serious universal remote rivaling some of the commercial ones available.
I was just stringing commands together with a delay of (40) between each transmission and it seems to work ok. Just wondering if you have a different way of creating macros or if you could recommend optimum delay values, etc.
Thanks for the library Ken. Question: will your examples work with an UNO? I think I have everything right and the codes I recorded match a work lirc configuration but I just don't seem to be able to get the stereo device to recognize the output. Any help is greatly appreciated.
--Chris
I Need a little help with RC5, I was able to transmit using NEC with no problems but my television will not respond to codes using the RC5 protocol.
#include
IRsend irsend;
void setup() {
}
void loop() {
irsend.sendRC5(0x26, 20);
delay(100);
}
what am i doing wrong? what should the number of bits be? 26 is whats reported (in hex) as being the power code.
I am setting up an Arduino Uno to control remote control lights. IRRecord seems perfect to get the data I need. I modified IRRecord to output codelen and to output rawCodes after the irsend.sendRaw command.
Serial output:
Received unknown code, saving as raw
23
m1450 s300 m1250 s400 m450 s1300 m1250 s400 m400 s1300 m400 s1300 m1250 s400 m450 s1250 m400 s1300 m400 s1300 m400 s1250 m400
Pressed, sending
Sent raw
1450 300 1250 400 450 1300 1250 400 400 1300 400 1300 1250 400 450 1250 400 1300 400 1300 400 1250 400
Released
This does not activate the lights. However, if I cut/paste the codes into an array as per Luckylarry's example, it works.
Any idea why IRRecord does not?
Thanks for the library. I am using IRHashdecode for another application with no problems.
Mike
Thanks for the great library!
All remote capture is perfect, but one remote for panasonic tv not recognized.
I try to use panasonic decode function- it do not recognize.
Remote work in Pronto format
dum of recive codes:
1
Raw (76):
-17316 3550 -1650 500 -350 550 -1200 450 -400 550 -350 500 -350 500 -400 450 -400 450 -400 500 -400 500 -350 500 -350 500 -400 450 -400 500 -1250 450 -400 500 -350 500 -400 450 -400 500 -350 500 -400 500 -350 450 -400 500 -400 450 -1300 450 -400 500 -350 500 -400 450 -400 500 -350 500 -400 450 -400 500 -350 500 -400 500 -350 500 -350 550 -350 450
2
Raw (76):
-10870 3450 -1700 500 -350 500 -1250 500 -350 500 -350 500 -400 450 -400 500 -350 450 -450 450 -400 450 -400 500 -350 500 -400 450 -400 450 -1300 450 -400 500 -350 500 -350 450 -450 450 -400 450 -400 500 -400 500 -350 450 -400 500 -1250 500 -350 450 -400 500 -400 450 -400 500 -350 500 -400 450 -400 500 -350 450 -1300 450 -400 500 -350 500 -400 450
3
Raw (76):
-892 3500 -1700 500 -350 500 -1250 450 -400 450 -400 500 -400 450 -400 450 -400 500 -350 500 -400 450 -400 500 -350 450 -450 450 -400 450 -1250 500 -400 450 -400 500 -350 500 -400 500 -350 450 -400 500 -350 550 -350 450 -400 500 -1250 450 -400 450 -400 500 -350 500 -400 450 -400 500 -350 450 -450 450 -400 450 -400 500 -1250 450 -400 500 -350 500
A hint for the new Arduino 1.0 version:
To get this library running under Arduino 1.0 you need to change one line of code in the file IRremoteInt.h:
line 15: from WProgram.h -> Arduino.h
That is all...
Hello, I need help to send a IR command. It is a signal from a IR fan remote. It is 0xC08, 11 bit, but it isn't sony, nec or the other protocol. How can I send it?
Thanks!!
Excuse my bad english, I'm Italian!
At First I was using this, thanks for the guide-lines.
Arduino
Hi,
sorry for my bad english.
I want create a bluetooth remote infrared with Arduino and Android.
I find a java parser for lirc conf file and I want test it.
It is possible create a most generic send function on arduino for codes parsed by Android?
I have all info and data from lirc file and i think it is possible compute a raw send data with Android and send it to arduino via bluetooth. The arduino decode it to IR Led.
First off, awesome library. Works great.
I plan on using multiple infrared sensors. How would the library support that?
I'm looking in the neighborhood of 15-20 infrared sensors.
I Love this project! I am putting this circuit into a pocket watch. Because of the limited space I am using an attiny85. I cannot laod this program onto it without an error however:
IRrecord.cpp: In function ‘void setup()’:
IRrecord.cpp:36:3: error: ‘Serial’ was not declared in this scope
IRrecord.cpp: In function ‘void storeCode(decode_results*)’:
IRrecord.cpp:55:5: error: ‘Serial’ was not declared in this scope
IRrecord.cpp:72:37: error: ‘DEC’ was not declared in this scope
IRrecord.cpp:78:7: error: ‘Serial’ was not declared in this scope
IRrecord.cpp:86:7: error: ‘Serial’ was not declared in this scope
IRrecord.cpp:89:7: error: ‘Serial’ was not declared in this scope
IRrecord.cpp:92:7: error: ‘Serial’ was not declared in this scope
IRrecord.cpp:95:7: error: ‘Serial’ was not declared in this scope
IRrecord.cpp:96:30: error: ‘DEC’ was not declared in this scope
IRrecord.cpp:99:5: error: ‘Serial’ was not declared in this scope
IRrecord.cpp:99:36: error: ‘HEX’ was not declared in this scope
IRrecord.cpp: In function ‘void sendCode(int)’:
IRrecord.cpp:109:7: error: ‘Serial’ was not declared in this scope
IRrecord.cpp:113:7: error: ‘Serial’ was not declared in this scope
IRrecord.cpp:114:33: error: ‘HEX’ was not declared in this scope
IRrecord.cpp:119:5: error: ‘Serial’ was not declared in this scope
IRrecord.cpp:120:31: error: ‘HEX’ was not declared in this scope
IRrecord.cpp:131:7: error: ‘Serial’ was not declared in this scope
IRrecord.cpp:132:33: error: ‘HEX’ was not declared in this scope
IRrecord.cpp:137:7: error: ‘Serial’ was not declared in this scope
IRrecord.cpp:138:33: error: ‘HEX’ was not declared in this scope
IRrecord.cpp:144:5: error: ‘Serial’ was not declared in this scope
IRrecord.cpp: In function ‘void loop()’:
IRrecord.cpp:154:5: error: ‘Serial’ was not declared in this scope
IRrecord.cpp:159:5: error: ‘Serial’ was not declared in this scope
How can I use this sketch with the attiny85?
Hello Ken, i am trying to work with your library in one Arduino MEGA 2560. The sendRaw function is not working. I tested all PWM ports, from 2 to 13 on board, and i could not see the IR Led blinking with my camera. Any ideas ? Thanks a lot!!!!
I just wanted to echo what someone said higher up - the default sending example, using delay(100), does not work with my Sony receiver. Changing it to delay(50) works perfectly. Lower than delay(50) seems to cause issues.
Hi
I have attached a Beolink IR eye (455kHz carrier frequency)
The receiver is picking up a lot of noise when my room is dark and can be canceled by turning on the light.
Also the raw codes I receive with the IRrecvDump is pretty much the same for all the buttons on my remote (a Bang & Olufsen Beo4 remote).
This it what I get when I press the up/down button:
Raw (26): -13900 1650 -1450 1650 -4600 1600 -4600 1650 -4550 1650 -4600 1600 -4600 1600 -4600 1650 -4600 1600 -4600 1600 -4600 1600 -4650 1600 -4650 1600
And I receive the exact same code/pattern for different buttons, but with less/more codes. 22/24/26 raw codes...
Can anyone help my with this?
Thanks!
Hi thanks for the library its great I was just wondering how the IR receive works,is it constantly polling for an interrupt which would then be triggered by the code read in?.
Post a Comment