A Multi-Protocol Infrared Remote Library for the Arduino

Code now on github

The most recent code is at github.com/shirriff/Arduino-IRremote. If you have any issues, please report them there.

Do you want to control your Arduino with an IR remote? Do you want to use your Arduino to control your stereo or other devices? This IR remote library lets you both send and receive IR remote codes in multiple protocols. It supports NEC, Sony SIRC, Philips RC5, Philips RC6, and raw protocols. If you want additional protocols, they are straightforward to add. The library can even be used to record codes from your remote and re-transmit them, as a minimal universal remote.

Arduino IR remote

To use the library, download from github and follow the installation instructions in the readme.

How to send

This infrared remote library consists of two parts: IRsend transmits IR remote packets, while IRrecv receives and decodes an IR message. IRsend uses an infrared LED connected to output pin 3. To send a message, call the send method for the desired protocol with the data to send and the number of bits to send. The examples/IRsendDemo sketch provides a simple example of how to send codes:
#include <IRremote.h>
IRsend irsend;

void setup()
{
  Serial.begin(9600);
}

void loop() {
  if (Serial.read() != -1) {
    for (int i = 0; i < 3; i++) {
      irsend.sendSony(0xa90, 12); // Sony TV power code
      delay(100);
    }
  }
} 
This sketch sends a Sony TV power on/off code whenever a character is sent to the serial port, allowing the Arduino to turn the TV on or off. (Note that Sony codes must be sent 3 times according to the protocol.)

How to receive

IRrecv uses an infrared detector connected to any digital input pin.

The examples/IRrecvDemo sketch provides a simple example of how to receive codes:

#include <IRremote.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
  }
}
The IRrecv class performs the decoding, and is initialized with enableIRIn(). The decode() method is called to see if a code has been received; if so, it returns a nonzero value and puts the results into the decode_results structure. (For details of this structure, see the examples/IRrecvDump sketch.) Once a code has been decoded, the resume() method must be called to resume receiving codes. Note that decode() does not block; the sketch can perform other operations while waiting for a code because the codes are received by an interrupt routine.

Hardware setup

The library can use any of the digital input signals to receive the input from a 38KHz IR receiver module. It has been tested with the Radio Shack 276-640 IR receiver and the Panasonic PNA4602. Simply wire power to pin 1, ground to pin 2, and the pin 3 output to an Arduino digital input pin, e.g. 11. These receivers provide a filtered and demodulated inverted logic level output; you can't just use a photodiode or phototransistor. I have found these detectors have pretty good range and easily work across a room.

IR wiring

For output, connect an IR LED and appropriate resistor to PWM output pin 3. Make sure the polarity of the LED is correct, or it won't illuminate - the long lead is positive. I used a NTE 3027 LED (because that's what was handy) and 100 ohm resistor; the range is about 15 feet. For additional range, you can amplify the output with a transistor.

Some background on IR codes

An IR remote works by turning the LED on and off in a particular pattern. However, to prevent inteference from IR sources such as sunlight or lights, the LED is not turned on steadily, but is turned on and off at a modulation frequency (typically 36, 38, or 40KHz). The time when a modulated signal is being sent will be called a mark, and when the LED is off will be called a space.

Each key on the remote has a particular code (typically 12 to 32 bits) associated with it, and broadcasts this code when the key is pressed. If the key is held down, the remote usually repeatedly broadcasts the key code. For an NEC remote, a special repeat code is sent as the key is held down, rather than repeatedly sending the code. For Philips RC5 or RC6 remotes, a bit in the code is toggled each time a key is pressed; the receiver uses this toggle bit to determine when a key is pressed down a second time.

On the receiving end, the IR detector demodulates this signal, and outputs a logic-level signal indicating if it is receiving a signal or not. The IR detector will work best when its frequency matches the sender's frequency, but in practice it doesn't matter a whole lot.

The best source I've found for details on the various types of IR codes is SB IR knowledge base.

Handling raw codes

The library provides support for sending and receiving raw durations. This is intended mainly for debugging, but can also be used for protocols the library doesn't implement, or to provide universal remote functionality.

The raw data for received IR measures the duration of successive spaces and marks in 50us ticks. The first measurement is the gap, the space before the transmission starts. The last measurement is the final mark.

The raw data for sending IR holds the duration of successive marks and spaces in microseconds. The first value is the first mark, and the last value is the last mark.

There are two differences between the raw buffers for sending and for receiving. The send buffer values are in microseconds, while the receive buffer values are in 50 microsecond ticks. The send buffer starts with the duration of the first mark, while the receive buffer starts with the duration of the gap space before the first mark. The formats are different because I considered it useful for the library to measure gaps between transmissions, but not useful for the library to provide these gaps when transmitting. For receiving, 50us granularity is sufficient for decoding and avoids overflow of the gaps, while for transmitting, 50us granularity is more than 10% error so 1us granularity seemed better.

Obtaining codes for your remote

The easiest way to obtain codes to work with your device is to use this library to decode and print the codes from your existing remote.

Various libraries of codes are available online, often in proprietary formats. The Linux Infrared Remote Control project (LIRC), however, has an open format for describing codes for many remotes. Note that even if you can't find codes for your exact device model, a particular manufacturer will usually use the same codes for multiple products.

Beware that other sources may be inconsistent in how they handle these protocols, for instance reversing the order, flipping 1 and 0 bits, making start bits explicit, dropping leading or trailing bits, etc. In other words, if the IRremote library yields different codes than you find listed elsewhere, these inconsistencies are probably why.

Details of the receiving library

The IRrecv library consists of two parts. An interrupt routine is called every 50 microseconds, measures the length of the marks and spaces, and saves the durations in a buffer. The user calls a decoding routine to decode the buffered measurements into the code value that was sent (typically 11 to 32 bits).

The decode library tries decoding different protocols in succession, stopping if one succeeds. It returns a structure that contains the raw data, the decoded data, the number of bits in the decoded data, and the protocol used to decode the data.

For decoding, the MATCH macro determine if the measured mark or space time is approximately equal to the expected time.

The RC5/6 decoding is a bit different from the others because RC5/6 encode bits with mark + space or space + mark, rather than by durations of marks and spaces. The getRClevel helper method splits up the durations and gets the mark/space level of a single time interval.

For repeated transmissions (button held down), the decoding code will return the same decoded value over and over. The exception is NEC, which sends a special repeat code instead of repeating the transmission of the value. In this case, the decode routine returns a special REPEAT value.

In more detail, the receiver's interrupt code is called every time the TIMER1 overflows, which is set to happen after 50 microseconds. At each interrupt, the input status is checked and the timer counter is incremented. The interrupt routine times the durations of marks (receiving a modulated signal) and spaces (no signal received), and records the durations in a buffer. The first duration is the length of the gap before the transmission starts. This is followed by alternating mark and space measurements. All measurements are in "ticks" of 50 microseconds.

The interrupt routine is implemented as a state machine. It starts in STATE_IDLE, which waits for the gap to end. When a mark is received, it moves to STATE_MARK which times the duration of the mark. It then alternates between STATE_MARK and STATE_SPACE to time marks and spaces. When a space of sufficiently long duration is received, the state moves to STATE_STOP, indicating a full transmission is received. The interrupt routine continues to time the gap, but blocks in this state.

The STATE_STOP is used a a flag to indicate to the decode routine that a full transmission is available. When processing is done, the resume() method sets the state to STATE_IDLE so the interrupt routine can start recording the next transmission. There are a few things to note here. Gap timing continues during STATE_STOP and STATE_IDLE so an accurate measurement of the time between transmissions can be obtained. If resume() is not called before the next transmission starts, the partial transmission will be discarded. The motivation behind the stop/resume is to ensure the receive buffer is not overwritten while it is still being processed; debugging becomes very difficult if the buffer is constantly changing.

Details of the sending library

The transmission code is straightforward. To ensure accurate output frequencies and duty cycles, I use the PWM timer, rather than delay loops to modulate the output LED at the appropriate frequency. (See my Arduino PWM Secrets article for more details on the PWM timers.) At the low level, enableIROut sets up the timer for PWM output on pin 3 at the proper frequency. The mark() method sends a mark by enabling PWM output and delaying the specified time. The space() method sends a space by disabling PWM output and delaying the specified time.

The IRremote library treats the different protocols as follows:

NEC: 32 bits are transmitted, most-significant bit first. (protocol details)

Sony: 12 or more bits are transmitted, most-significant bit first. Typically 12 or 20 bits are used. Note that the official protocol is least-significant bit first. (protocol details) For more details, I've written an article that describes the Sony protocol in much more detail: Understanding Sony IR remote codes.

RC5: 12 or more bits are transmitted most-significant bit first. The message starts with the two start bits, which are not part of the code values. (protocol details)

RC6: 20 (typically) bits are transmitted, most-significant bit first. The message starts with a leader pulse, and a start bit, which is not part of the code values. The fourth bit is transmitted double-wide, since it is the trailer bit. (protocol details)

For Sony and RC5/6, each transmission must be repeated 3 times as specified in the protocol. The transmission code does not implement the RC5/6 toggle bit; that is up to the caller.

Adding new protocols

Manufacturers have implemented many more protocols than this library supports. Adding new protocols should be straightforward if you look at the existing library code. A few tips: It will be easier to work with a description of the protocol rather than trying to entirely reverse-engineer the protocol. The durations you receive are likely to be longer for marks and shorter for spaces than the protocol suggests. It's easy to be off-by-one with the last bit; the last space may be implicit.

Troubleshooting

To make it easier to debug problems with IR communication, I have optional debugging code in the library. Add #define DEBUG to the beginning of your code to enable debugging output on the serial console. You will need to delete the .o files and/or restart the IDE to force recompilation.

Problems with Transmission

If sending isn't working, first make sure your IR LED is actually transmitting. IR will usually show up on a video camera or cell phone camera, so this is a simple way to check. Try putting the LED right up to the receiver; don't expect a lot of range unless you amplify the output.

The next potential problem is if the receiver doesn't understand the transmitter, for instance if you are sending the wrong data or using the wrong protocol. If you have a remote, use this library to check what data it is sending and what protocol it is using.

An oscilloscope will provide a good view of what the Arduino or a remote is transmitting. You can use an IR photodiode to see what is getting transmitted; connect it directly to the oscilloscope and hold the transmitter right up to the photodiode. If you have an oscilloscope, just connect the oscilloscope to the photodiode. If you don't have an oscilloscope, you can use a sound card oscilloscope program such as xoscope.

The Sony and RC5/6 protocols specify that messages must be sent three times. I have found that receivers will ignore the message if only sent once, but will work if it is sent twice. For RC5/6, the toggle bit must be flipped by the calling code in successive transmissions, or else the receiver may only respond to a code once.

Finally, there may be bugs in this library. In particular, I don't have anything that receives RC5/RC6, so they are untested.

Problems with Receiving

If receiving isn't working, first make sure the Arduino is at least receiving raw codes. The LED on pin 13 of the Arduino will blink when IR is being received. If not, then there's probably a hardware issue.

If the codes are getting received but cannot be decoded, make sure the codes are in one of the supported protocols. If codes should be getting decoded, but are not, some of the measured times are probably not within the 20% tolerance of the expected times. You can print out the minimum and maximum expected values and compare with the raw measured values.

The examples/IRrecvDump sketch will dump out details of the received data. The dump method dumps out these durations but converts them to microseconds, and uses the convention of prefixing a space measurement with a minus sign. This makes it easier to keep the mark and space measurements straight.

IR sensors typically cause the mark to be measured as longer than expected and the space to be shorter than expected. The code extends marks by 100us to account for this (the value MARK_EXCESS). You may need to tweak the expected values or tolerances in this case.

The library does not support simultaneous sending and receiving of codes; transmitting will disable receiving.

Applications

I've used this library for several applications:

Other projects that use this library

Other Arduino IR projects

I was inspired by Building a Universal Remote with an Arduino; this doesn't live up to being a universal remote, but has a lot of information. The NECIRrcv library provided the interrupt handling code I use.

896 comments:

«Oldest   ‹Older   801 – 896 of 896
Anonymous said...

Which output pin does the IR led need to be connected to on the Arduino Due?

Anonymous said...

First of all, awesome library Shirriff. Thanks its tremendously helpful. Great work on your recent IBM 1401 mainframe bitcoin miner too. Pretty neat stuff.


I've been working on a 'serial interface remote' project and had a weird issue- looked through the blog, didn't see any similar issues so I thought I'd bring it up in case someone has similar problems. Maybe it's just an oversight on my part, but idk, here it is anyway.

Here's the problem.
IR Reciever and IRrecord sketches capture the "power on/off" button code from my Epson H562A Projector as NEC: C1AA09F6, 32 bit.

I have no problem transmitting NEC protocols to other devices so I know my syntax and conventions are correct, but playback or irSend.NEC() fail to power on the device!

I tried the IRrecvDump sketch and an irSend.sendRaw() with the resulting codes, but no dice! (I'm confident with my syntax there too).

Then I decided to transmit the code from my android device instead of the Epson remote and see what happened. What do you know!? It recorded the ir burst as a raw instead of a NEC! I plugged in the recorded data into the irSend.sendRaw() method and viola! Worked like a charm.

To anybody who knows what the deal is here, school me. I'm curious what's going on. To those with similar problems and looking for the quick answer, try this for your array:

unsigned int pwr[67] ={8750,4600,400,1800,400,1850,400,700,400,700,400,700,400,750,400,700,400,1800,400,1850,400,700,400,1800,400,700,400,1850,400,700,400,1800,400,700,400,750,400,700,400,700,400,700,400,1850,400,700,400,700,400,1800,400,1850,400,1800,400,1850,400,1800,400,700,400,1850,400,1800,400,700,400 };

and this for your irSend:
irsend.sendRaw(pwr, 67, 38);

Wackychimp said...

I'm loving this library but having some trouble using the RAW codes. I need to send commands to and Audiovox portable DVD player so (I believe) RAW is the only way to go for me.

My question is actually on the receiving end: how do I evaluate if the code I received is the correct code? I can't put a big RAW list in an IF statement (can I?). I've got something like this now (sorry, it's on my home computer and I'm at work when posting - this is approximation):

unsigned int rawCodes[] = {8850, 4550, 450, 2300, 450, 4500, 450, 2250, 500, 4500, 450, 2250, 500, 2250, 450, 2250, 500, 2250, 450, 2300, 450, 2250, 500, 2250, 450, 2250, 500, 2250, 450, 4500, 500, 4500, 450, 2250, 500};

if (results.value == rawCodes) {
do fun stuff here
}

As I understand it if even one of those is off (sometimes a 500 will be 550) then I'll get a false and can't trip my code.

Any suggestions greatly appreciated.

Unknown said...

hi im try to make a universal contol remote but i have a very big broblem with the ir send I cant turn it on if you can help me with that I appreciate it

im using arduino uno IDE 1.6.4

arishy said...

My problem is I do not have the original IR remote. An old Universal IR remote I had ( Lost it too !!); has a SETUP key that you keep pressing until the device under test is switched off or on This way that little remote DISCOVERED the protocol used by the device under test.

Can one emulate such function and let LIRC spell out the unknown IR protocol then build a file for it.
Am I pushing my luck here ???

Unknown said...

Is this library will work with TSOP 1738

Rizal Fahlevi said...

I use this library too Ken. Thanks a lot!
But I have a question. I used NEC protocol for my LG television. And I already record it. But when I tried to send the code again, I need to repeat it from 2 - 8 times to get the same code from the remote. Do you know what's wrong with my project?

Richard Morris said...

Hi Ken

I've been using your IRremote library for a few months now, and haven't had any problems whatsoever... But, I recently upgraded my Arduino IDE (Windows) to 1.6.0 as my next project is based on the Arduino Yun, and now discovered my existing IR-based projects are no longer compiling with this release...

The error I'm seeing is:
C:\TOOLS\arduino-1.6.0-windows\arduino-1.6.0\libraries\RobotIRremote\src\IRremoteTools.cpp:5:16: error: 'TKD2' was not declared in this scope
int RECV_PIN = TKD2; // the pin the IR receiver is connected to
^
Error compiling.

Looks like version 1.6.0 includes a library called "RobotIRremote" which includes IRremote.cpp and IRremote.h, and this appears to be stopping my projects from compiling. I've tried switching the Board to Leonardo or Yun, but that doesn't seem to help.

All my code is doing to include the library is:
#include

I've tired downloading the library and placing in the x:\\libraries\IRremote but that has not helped either.

Do you happen to know if there is any way of stopping the compiler attempting to use this RobotIRremote library (despite the fact I'm not including it anywhere in my code) and force it to use to the version in x:\\Arduino\libraries instead ?

kind regards,
Richard

Wackychimp said...

Richard, remove that robots folder from your libraries directory. I just moved mine up a level and renamed it with "-HOLD" on it in case I wanted it later.

I'm using the duemilanove though. Hope this helps you.

Richard Morris said...

Thanks Wackychimp, that sorted the problem.... I can certainly live that solution, although would be nice if the Arduino IDE gave more control over library selections in cases like this... Thanks anyway!

-Richard

Anonymous said...

Hi Ken, I am having a conflict with your library and an existing library in Arduino 1.6.5. The problem seems to be with a library called RobotIRRemote, which I think is a modified version of yours. The two don't play nicely together. How would you recommend proceeding?

Thanks!

Unknown said...

ken i dont know what to do
my arduino IDE says the following error message

Arduino: 1.6.5 (Windows 8), Board: "Arduino Uno"

C:\Program Files\Arduino\libraries\RobotIRremote\src\IRremoteTools.cpp:5:16: error: 'TKD2' was not declared in this scope
int RECV_PIN = TKD2; // the pin the IR receiver is connected to
^
Multiple libraries were found for "IRremote.h"

Used: C:\Program Files\Arduino\libraries\RobotIRremote

Not used: C:\Users\Suryaprakasam\Documents\Arduino\libraries\Arduino-IRremote-master

Error compiling.

This report would have more information with
"Show verbose output during compilation"
enabled in File > Preferences.

Unknown said...

Hi Ken,

I am using a IR Safe Beam as source IR NOT wired to Arduino.

I have captured signal with IR detector with your IRRecord code.

Data captured:
Received unknown code, saving as raw
m100 s2850 m100 s2850 m200 s2800 m250 s2750 m200 s2750 m300 s2700 m300 s2750 m250 s2750 m250 s2750 m250 s2700 m300 s2750 m250 s2750 m250 s2750 m250 s2700 m300 s2700 m300 s2750 m250 s2750 m250 s2750 m250 s2750 m250 s2750 m300 s2650 m350 s2650 m350 s2650 m350 s2700 m300 s2700 m300 s2700 m300 s2700 m350 s2650 m350 s2650 m350 s2650 m350 s2650 m350 s2650 m350 s2650 m350 s2650 m350 s2650 m350 s2650 m350 s2650 m350 s2650 m350 s2650 m350 s2700 m300 s2700 m300 s2700 m350 s2650 m350 s2650 m350 s2650 m350 s2650 m350 s2650 m350 s2650 m350 s2650 m350 s2650

I want to use the IR signal to control ON or OFF for motor on balancing machine for drive shafts.

I think data suggests IR is pulsing off/on???
OFF - 300 - 350ms(off)
ON - 2650 - 2750ms(on)

The raw data I captured is varchar?
Or measured time as Int?

I think , if I can get time OFF and time ON I can check for pattern change to control motor.

Am I on the right track? Thanks for any suggestions.

Best regards,
David

Unknown said...

@Ken
hi, i want to do aa project in arduino uno and i tried to work with 2 ir recievers with ur librery and it didnt work . can you please give me an advice or a code so i can work with 2 or 3 ir recievers ?

please send to
[email protected]



this is the code that doesnt work for me :

#include

int IRpin = 11;
int IRpin2 = 10;
IRrecv irrecv(IRpin);
IRrecv irrecv2(IRpin2);
decode_results results;




void setup()
{
Serial.begin(9600);
irrecv.enableIRIn(); // Start the receiver
irrecv2.enableIRIn();

}

void loop()
{
if (irrecv.decode(&results))
{
Serial.println("read1");
Serial.println(results.value, DEC); // Print the Serial 'results.value'
irrecv.resume(); // Receive the next value

}



if (irrecv2.decode(&results))
{
Serial.println("read2");
Serial.println(results.value, DEC); // Print the Serial 'results.value'
irrecv2.resume(); // Receive the next value
}





}


thank you very much

Ritvars said...

Hi,
just want to say thanks for so good written library. Works with any Arduino IDE-es version without glitches.

Unknown said...

I just wanted to say thanks, Ken. You've made what would normally be a long, painstaking process really simple. It took me only about 10 minutes to set up then record all of the codes from my 'HotPoint' air conditioner remote, so I can use it to control my robot car. It sends the code once, then a stream of 0xFFFFFFFF until the button is released and pressed again. Perfect.
And it couldn't have been simpler. :)
Thanks once again,
Steve.

Unknown said...

I'm really curious that why the the timer2 interval is configured to 50uS and i think the smaller the interval is and the higher the precision of the infrared decoding will be, i.e, the USECPERTICK is fixed to 40 and the intrerval will be 40uS.( Only one parameter needs to be modifie
Thanks andvance for your help and sorry for my poor English!!!

Bernd said...

WOW, Thanks a lot for this library!

It took me only 4 hours to build up the Arduino hardware with IR receiver and IR sender,
record the codes from my FujiDenzo aircon and now I can control the aircon from my Arduino already!

Great stuff!

Luciano Pautasso said...

Hi ,
i compiled IRrecvDump whit older Arduino IDE and was all ok.

Now, with last version 1.6.7 of IDE have this errors:

Arduino:1.6.7 (Windows 7), Scheda:"Arduino/Genuino Uno"

C:\Program Files\Arduino\libraries\RobotIRremote\src\IRremote.cpp:70:6: error: 'IRsend' has not been declared

void IRsend::sendNEC(unsigned long data, int nbits)

^

C:\Program Files\Arduino\libraries\RobotIRremote\src\IRremote.cpp: In function 'void sendNEC(long unsigned int, int)':

C:\Program Files\Arduino\libraries\RobotIRremote\src\IRremote.cpp:72:17: error: 'enableIROut' was not declared in this scope

enableIROut(38);

^

C:\Program Files\Arduino\libraries\RobotIRremote\src\IRremote.cpp:73:20: error: 'mark' was not declared in this scope

mark(NEC_HDR_MARK);

^

C:\Program Files\Arduino\libraries\RobotIRremote\src\IRremote.cpp:74:22: error: 'space' was not declared in this scope

space(NEC_HDR_SPACE);

^

C:\Program Files\Arduino\libraries\RobotIRremote\src\IRremote.cpp: At global scope:

C:\Program Files\Arduino\libraries\RobotIRremote\src\IRremote.cpp:90:6: error: 'IRsend' has not been declared

void IRsend::sendSony(unsigned long data, int nbits) {

^

C:\Program Files\Arduino\libraries\RobotIRremote\src\IRremote.cpp: In function 'void sendSony(long unsigned int, int)':

C:\Program Files\Arduino\libraries\RobotIRremote\src\IRremote.cpp:91:17: error: 'enableIROut' was not declared in this scope

enableIROut(40);

^

C:\Program Files\Arduino\libraries\RobotIRremote\src\IRremote.cpp:92:21: error: 'mark' was not declared in this scope

mark(SONY_HDR_MARK);

^

C:\Program Files\Arduino\libraries\RobotIRremote\src\IRremote.cpp:93:23: error: 'space' was not declared in this scope

space(SONY_HDR_SPACE);

^

C:\Program Files\Arduino\libraries\RobotIRremote\src\IRremote.cpp: At global scope:

C:\Program Files\Arduino\libraries\RobotIRremote\src\IRremote.cpp:108:6: error: 'IRsend' has not been declared

void IRsend::sendRaw(unsigned int buf[], int len, int hz)




..... and more



C:\Program Files\Arduino\libraries\RobotIRremote\src\IRremote.cpp:1009:6: error: 'IRsend' has not been declared

void IRsend::sendDISH(unsigned long data, int nbits)

^

exit status 1
Errore durante la compilazione

Questo report potrebbe essere più ricco di informazioni con
"Mostra un output dettagliato durante la compilazione"
abilitato in "File > Impostazioni"

Nicolae said...

Hi Ken,

I used your libraries to identify the code sent by a remote control for a Kogan TV. The software detects the remote as a NEC and the codes have a size of 28 bits (for example Power On/Off is 0x2FD807F). However, when I send the same code to the TV, it does not react. I am not clear if it enough to send the code just one time or do I have to send some repeats or what else (I tried sending the code multiple times with various delays, sending 0xFFFFFFFF for repeats, etc). Is it possible that the software identifies the code incorrectly as NEC? Maybe there is something slightly different in the protocol? I used two Arduinos and when I send the codes from one board, the receiving board decodes the command as expected - however the TV does not respond.

Nick

Nicolae said...

Hi Ken,

Just solved it. It is indeed NEC code. However, I was sending 28 bits (this is how many bits are in 0x2FD807F), I noticed that the software IRrecvDump indicated that 32 bits are received. So, I changed the number of bits to 32. On the other hand, I wonder why does the user have to specify the number of bits to send - wouldn't be easy enough for the software to count itself the number of bits?

Nick

TUSHAR said...

please help me resolve this error
Arduino: 1.6.5 (Windows 8.1), Board: "Arduino Uno"

C:\Program Files (x86)\Arduino\libraries\RobotIRremote\src\IRremoteTools.cpp:5:16: error: 'TKD2' was not declared in this scope
int RECV_PIN = TKD2; // the pin the IR receiver is connected to
^
Multiple libraries were found for "IRremote.h"

Used: C:\Program Files (x86)\Arduino\libraries\RobotIRremote

Not used: C:\Users\TUSHARNAND\Documents\Arduino\libraries\Arduino-IRremote-master

Error compiling.

This report would have more information with
"Show verbose output during compilation"
enabled in File > Preferences.
Any kind of help would be appreciatesd ..Thank you

Nicolae said...

Tushar, you have to remove the folder\RobotIRremote from folder libraries, because the compiler uses the wrong library. If you want to keep that library, just move it to a different location.

Anonymous said...

Have you been able to get this library to work using the Sparkfun emitter/detector pair (https://www.sparkfun.com/products/241)? Using the IRremote library, I'm able to detect and decode signals from my TV remote, stereo, and my kid's Lego train remote. However, I'm not able to then turn around and get the emitter to send the same thing so that the detector decodes it.

I've set up two breadboards, one the emitter and one the detector. I can't command *any* code, using any protocol supported by the library, and get the detector to decode it. But I know the detector works because I can use the remote itself and properly decode the signal.

I know the emitter is working because if I just drive the emitter (not a specific code), the detector sees something. But as soon as I try to drive a specific code, the "decode" function returns nothing.

Nicolae said...
This comment has been removed by the author.
Nicolae said...

Both the receiver and the emitter work for me. I also had problems with the emitter - I was sending 28 bits initially, but when I used one of the decoder examples, I noticed that they interpret my tv remote as sending 32 bits, so after I change the code length to 32 in the emitter software, it started working. In order to be sure the circuit was set up correctly (the emitter pin), I installed a red led and was checking if it flashes while transmitting. I also noticed that I was able to control my tv with the red led from close proximity (a few cm). Also a white super-bright led worked for my tv. You have to pay attention to which pin is selected in code to transmit, then verify with a visible led that it flashes.

GooN said...

Hello,

Is it possible to make it work along with other libraries that uses Timer2?

Thanks

electrik77 said...

Amazing code Ken.
I have a problem sending the code.
With IRrecv Dump and the original remote control I get:
D010020A
Decoded NEC: D010020A (32 bits)
Raw (74): -7402 9000 -4350 750 -1500 750 -1550 750 -450 750 -1500 750 -450 750 -450 750 -450 700 -450 750 -450 750 -450 750 -450 700 -1550 750 -450 750 -450 750 -450 700 -450 750 -450 750 -450 700 -500 700 -500 700 -450 750 -450 700 -1600 700 -450 750 -450 700 -500 700 -500 700 -500 700 -1550 700 -500 700 -1600 700 -450 700 -500 700 -1600 700 -450 700

Loading on the Arduino Uno this code:
#include "IRremote.h"

IRsend irsend;

void setup()
{

Serial.begin(9600);
}

void loop()
{
//Replace for your IR Code here.
irsend.sendNEC(0xD010020A, 32); //irsend.send(IRTYPE)(0x(IRCODE), (BITS));
delay(4000);
}

And reading with IRrecvDump which sends the Arduino I get:
D010020A
Decoded NEC: D010020A (32 bits)
Raw (68): -6696 9100 -4350 700 -1550 700 -1550 650 -450 650 -1600 700 -450 650 -450 650 -450 650 -500 650 -450 650 -450 650 -500 650 -1550 700 -450 650 -450 650 -450 700 -450 650 -450 650 -450 700 -450 650 -450 650 -450 700 -450 650 -1600 650 -450 650 -450 650 -500 600 -500 650 -450 650 -1600 650 -450 650 -1600 650 -500 600

It is an Air-conditioner
The original remote control is NEC code. Disassemble and inside has the NEC chip.
I do not understand the difference (Raw (74) and Raw (68)) but the air conditioner
unresponsive.
Sorry for my English

Unknown said...

Hello Every1. Found sumthng new reated to the same.
http://vaaiibhav.me/how-to-use-arduino-with-infrared-remote-control/

Unknown said...

Desmond Michael: Your website is plagarism.

Arsal said...

Hey... has anyone had experience using two IR sensors on the same uno/controller? I have been trying to do that but the output is just the same for both the sensors (even though its not supposed to be the same). My guess is that it has something to do with the IRremote library. Would be a huge help. Thanks...

Anonymous said...

How to setup the arduino code to activate two led end one relay through ir remote with two button?
first push of button1 activate led1 after some sec push button 2 then activate led2 end relay,after 30 sec automatically shut down two led-s but relay stey active,to shut down relay push button1 end button2 after 30 sec automatically shut down two led-s end relay.

DoDi said...

Thanks for the fine library :-)

I've developed some improvements on it, so that the standard methods begin(), available() and read() can be used with IRrecv.

Most important was a modification of the decoder selection, which now does not require any #defines or other modifications to the library. In begin() the user can specify the decoder to use, whereupon only that decoder is added to the program. This gives a considerable size and speed improvement to every program.

If you are interested, send a mail to [email protected].

J-W said...

Hi Ken,

Great Lib, thanks a million!

With some modification, I was able to finally use the "IR input" of my NAD amp C352. It takes a 5V UNMODULATED "ir" signal, active high. For that, I modded your Interrupt Service Routine to output a HIGH on a dedicated ouput pin everytime the ir input state from the ir module changed to STATE_MARK, and a LOW everytime it changed to STATE_SPACE.

And it worked!! And I'm a really bad programmer.

Regards & Thanks

Unknown said...

Great work and thank you. I did have the same Sony problem as somebody else however, found the answer here http://forum.arduino.cc/index.php?topic=76675.0 where they changed the delay from 100ms. After using a scope with the Sony remote, Sony appears to require a 45ms time between transmissions on new tvs. So I used the following loop with a 20ms delay (adjusted for the time it takes to run the loop) to give 45ms between sends...hope this helps someone else

for (int i = 0; i < 20; i++) {
irsend.sendSony(0xa90, 12); // Sony TV power code
delay(25); // Add delay to loop to achieve 45ms between transmissions
}

Unknown said...

Hi, I have been trying to do this project for ages and I am running out of time, if you could quickly reply that would be great thank you! My project is not working as my receiver and my remote don't seem to do anything. My code fr sending and receiving is
#include
#include

IRsend irsend;
int RECV_PIN = 11;
IRrecv irrecv(RECV_PIN);
decode_results results;

void setup()
{
Serial.begin(9600)
; irrecv.enableIRIn(); // Start the receiver
;}

void loop() {
if (Serial.read() != -1) {
for (int i = 0; i < 3; i++) {
irsend.sendSony(0xa90, 12); // Sony TV power code
delay(100);
}
}
if (irrecv.decode(&results)) {
Serial.println(results.value, HEX);
irrecv.resume(); // Receive the next value
}
}

I am new to the arduino PLEASE HELP THIS IS URGENT

IS THERE ANYTHING THAT I AM DOING WRONG?!

Unknown said...

Hi, Ken,
I recently downloaded your library to try to operate an air conditioner.
I had to change it because your library only supports 'Rawlen' of 100, resulting in 'overflow' reading the code on the remote control.
By expanding 'Rawlen', it turned out that the library decodes only up to 32 bits, while the remote control sends a NEC 64-bit code.
I had to change again the library to decode and send the code (only routines 'NEC') correctly.
Therefore, I have a possible solution for those who have encountered the same problem.
I see your library is 2009, so don't know if you keep on updating it. In case you're interested, I can send the modified code to the mail you indicate.
Please excuse if in this forum someone else has already posted a similar solution to mine to solve the problem, because I have not bothered to read the 800 messages sent.
Regards.

mephala.

Craig said...

Back I 2010, I posted the code I wrote to send Phillips RC5 extended commands. It turns out that code wasn't putting bit 7 of the command word in the right location! Here's a newer version.

/*
* Construct 13 of the 14 bits of a RC5 extended command
*
* (the 1st start bit is provided by irsend::sendRC5X())
* 2nd start bit/aka field bit/aka 7th command bit (inverted)
* toggle bit
* 5 bits of device
* 6 bits of command (OBC format)
*/
#define RC5XCODE(dev, obc, toggle) \
(((~(obc) & 0x40) << 6) | \
((toggle) << 11) | \
(((dev) & 0x1F) << 6) | \
((obc) & 0x3F))

/* XDPR1 XM Satellilte Radio remote RC5 device code */
#define DEV_XDPR1 27

/* 5 bit device/system */
#define DEV_MAX 0x1F

/* 7 bit obc */
#define OBC_MAX 0x7F

/* toggle bit + 5 bit device + 7 bit obc (bit 7 of obc shifted to field bit) */
#define RX5_NBITS (1 + 5 + 7)

void sendrc5(unsigned char);
void sendrc5x(unsigned long, int8_t);

/* Send a RC5 extended command to the XM receiver */
void
sendrc5(unsigned char obc)
{
sendrc5x(RC5XCODE(DEV_XDPR1, obc, toggle), RX5_NBITS);
toggle = !toggle;
}

/*
* RC5 extended
* 1st passed bit is the 2nd start bit/field bit/6th command bit
* 2nd passed bit is the toggle (caller handles flipping)
*/
void
sendrc5x(unsigned long data, int8_t nbits)
{
irsend.enableIROut(36);
data = data << (32 - nbits);
irsend.mark(RC5_T1); // First start bit
for (int8_t i = 0; i < nbits; ++i) {
if (data & TOPBIT) {
irsend.space(RC5_T1); // 1 is space, then mark
irsend.mark(RC5_T1);
} else {
irsend.mark(RC5_T1);
irsend.space(RC5_T1);
}
data <<= 1;
}
irsend.space(0); // Turn off at end
}

Abhishek said...

Hi Ken,
I have been struggling to Decode the Signal out of Samsung Air Conditioner Remote.
The IRremote library doesn't seem to recognize the protocol.

So I wrote a simple code using pulseIn() function of arduino to note down the time (in microseconds) for the HIGH and LOW states of the TSOP1738 data output pin.
The code is as follows:

//Basic Code to read TSOP1738 input

const int input_pin = 15;
int i = 0;

void setup() {
pinMode(input_pin, INPUT);
Serial.begin(9600);
}

void loop() {
int remote_val = read_remote();
if(remote_val>0)
{
Serial.println(remote_val);

}
}
int read_remote()
{
int time = pulseIn(input_pin, LOW); // Changing the LOW to HIGH will show timings for the
// other state
return time;

}


using pulseIn(input_pin, LOW) that shows time for HIGH states (mark) as TSOP inverts the data
The data I obtained is:
576
2948
489
494
493
491
500
446
446
468
491
486
489
488
488
489
489
488
487
487
462
482
487
497
495
496
478
433
2945
489
489
488
484
440
496
489
478
434
495
494
500
512
505
533
495
441
440
505
488
494
449
495
481
503
449
519
509
484
443
512
502
510

using instead pulseIn(input_pin, HIGH) will give the time for the LOW states (spaces):
The data I obtained is:
17689
8854
500
1479
502
525
494
548
538
539
517
1470
490
468
1468
463
462
1467
1519
490
468
494
501
460
465
1517
8796
1453
499
492
1495
524
1471
465
531
500
500
505
509
485
496
8834
1466
532
491
490
1480
1501
1462
496
1523
500
492
1476
519
470
1471


I understand that 560us mark followed by 560us space is a digital LOW (0)
and 560us mark followed by a 1690us space is a digital HIGH (1)
But I am unable to understand what does 17689, 8854 in pulseIn(...,HIGH) output and 2948 in pulseIn(..., LOW) output mean.
I am not able to figure out the protocol Samsung is using to send the data.

Also I tried to send this data as it is using an IR led but the Air Conditioner didn't recognize it.

I would be thankful for any help.

Unknown said...

Abhishek,
You faced same problem as me: Ken Shirriff library doesn't work for conditioned airs, because it's only able to decode 32 bits maximum. I've commented this limitation 2 posts earlier than yours.
So i decided expand the library to admit any code length, and tested in both NEC and Samsung codes.
I wrote to Ken offering it, but he doesn't answer. But if i can help somebody, i'll be happy doing it!.
First, i saw your timings obtained by pulseIn() function are inaccurate. Are better using Shirriff interrupt's routines, so you don't need to modify them, just expand code to allow the 72 bits code of Samsung IR (64 of NEC).
I did it creating an bool array, and filled with 1 or 0 upon decoding values.
To decode the signal, you should view the definitions in the IR_Samsung.cpp example file:
#define SAMSUNG_HDR_MARK 5000
#define SAMSUNG_HDR_SPACE 5000
#define SAMSUNG_BIT_MARK 560
#define SAMSUNG_ONE_SPACE 1600
#define SAMSUNG_ZERO_SPACE 560
#define SAMSUNG_RPT_SPACE 2250
I think it's pretty explained.
If you need more help, please ask for it!

mephala.

Ken Shirriff said...

mephala: Please send improvements, bug reports, etc to the IRremote github repository: github.com/shirriff/Arduino-IRremote. There is some discussion of air conditioner support there.

Abhishek said...

Thanks mephala,

I'll try expanding the library as you said.
I'll ask you if I need more help.

Me said...

Hi Ken, thanks for your Arduino-IRremote library but I got an error when compile examples IRrecord on board Genuino 101. It says "IRremote.cpp:21:27: fatal error: avr/interrupt.h: No such file or directory". How could I clear that.
thanks!

小玩意 said...

HI Ken:

Is IRremote library working at Teensy 3.2 board?
Must to modify code ?
Thank yu~

Booker

小玩意 said...

Ken :

Is Infrared Remote Library working at arduino-stm32 ?

Thank yu~

Unknown said...

Thank you very much. your job give a new life to my camera that was without a timed trigger.
Sony NEX -VG20

Unknown said...

why IRsend irsend; on code doesen't work

JoeO said...

Electronic - It works fine. You are doing something wrong.

TheArduinoGuy said...

Ken as far as I can tell there is no error checking in the IR data streams being transmitted. Do you know of any nice algorithms I could use for this please?

Thanks,

Mike

Unknown said...

hey ken,
i was trying to make a IR remote kind off, i am using NEC protocols, with your library and code i was able to send 1 single code only at a time, i want to have atleast 3 output signals at 3 different pins, so that i can have 3 different function performed by codes generated by each pin. could you help me with the program for this.

Unknown said...

Arduino: 1.6.11 (Windows 10), Board: "Arduino/Genuino Uno"

C:\Program Files (x86)\Arduino\libraries\RobotIRremote\src\IRremoteTools.cpp:5:16: error: 'TKD2' was not declared in this scope

int RECV_PIN = TKD2; // the pin the IR receiver is connected to

^


Anonymous said...

Google search:

'TKD2' was not declared in this scope

Unknown said...

Hi
Thanks for you reply

I catched this signal (vaccum remote) with mode2:

root@raspberrypi:/etc/lirc# mode2 -m -d /dev/lirc0
3467329

3062 992 1027 2994 991 3007
988 3005 2946 1032 998 3024
992 3004 992 21138 3055 1003
1026 2996 1000 2998 997 2995
2977 1002 1027 2995 990 3005
991 21137 3070 989 1017 3004
991 3005 991 3005 2978 1000
1019 3006 989 3004 992 21138
3056 999 1020 3003 993 3002
994 3001 2982 996 1026 2996
997 3000 995 21384 3062 996
1023 2999 996 3002 994 3000
2983 995 1023 2999 997 2999
996

My goal is to be able to reproduce it with irsend (raspberry pi)

i recorded with irrecord

$ irrecord -f -d /dev/lirc0 -f vaccum

the vaccum file is now like this:

begin remote

name vaccum
flags RAW_CODES|CONST_LENGTH
eps 30
aeps 100
gap 50192
begin raw_codes
name BTN_9
3057 992 1026 2995 1001 2995
1000 2995 2978 1003 1015 3002
994 3002 993
end raw_codes
end remote

i copied the vaccum file to lircd.conf and restart

$ /etc/init.d/lirc restart

unfortunatly nothing move when i do that:

irsend send_once vaccum BTN_9

My IRLed is working because i am able to control my TV with irrecord and irsend.

Can you help me ?

Regards

pyaraustad said...

i have to used IR library with dot matrix display My dot matrix display is updated every 1ms second by a interrupt if i use use IR library with dotmatix interrupt IR library give wrong value please tell me the solution for this.
Thanks

David said...

I learned a lot from your posts and had a lot of fun with the library you wrote. I made an Wireless Arduino Thumb Joystick Shield with the knowledge gained here and have ben sharing it in our Arduino Class

Jason Feemster said...

My friend David Riewe told me about your site. I've been having some fun learning about Arduino and have taken a few very, very basic online classes. So I am a newbie. I was wondering if it would be possible to come up with a POS system or basic cash register system with Arduino?

Jason Feemster
http://www.dallaspossystems.com

JoeO said...

Jason: It all depends on what features you want. Just a plain POS, yes. A fancy one with multiple graphic screens, probably not.

Unknown said...

Dear Mister Ken Shirriff,

Is it possible to define multiple PWM pins (as output) at once?
In the example code is written which pin is defined as pwm output.
How do i change this pin or add another pwm pin as output pin.

Thanks in regard,

Adeline

jems said...

Actually i want to detect IR raw code and same time it will send.
So, i will confirm code.Whether it works or not.
I did separate program but i could not use same time collect data and send as per collected data.
So, help me for this problem solution.

Unknown said...

Hi, I would like some advice on creating a game buzzer setup using 8 Arduinos and a Raspberry Pi with only IR LEDs and Receivers. How could I create unique IR Codes for each buzzer and have the Pi identify them correctly?

ablebaker said...

Thanks for producing this fine library. Very clearly written!

I found it simple to hack the RC6 routine so that it can decode the Vista / Ortek VRC-1100 MCE Remote. This remote seems to send a simplifed version of the RC6.

Some other things to consider:
1. The remote sends 3 bursts with 48ms between so adjust for that in your main code loop
2. The code is 17 bits long - pattern is Device:5,P(burstID):2,Function:6,CheckSum:4
so the function code is 6 bits sort of in the middle, you have to reverse these bits.

in ir_RC5_RC6.cpp

#define RC6_HDR_MARK 1950
#define RC6_HDR_SPACE 1000
#define RC6_T1 500

======

#if DECODE_RC6
bool IRrecv::decodeRC6 (decode_results *results)
{
int nbits;
long data = 0;
int used = 0;
int offset = 1; // Skip first space
if (results->rawlen < MIN_RC6_SAMPLES) return false ;
// Initial mark
if (!MATCH_MARK(results->rawbuf[offset++], RC6_HDR_MARK)) return false ;
if (getRClevel(results, &offset, &used, RC6_T1) != SPACE) return false ;
for (nbits = 0; offset < results->rawlen; nbits++) {
int levelA, levelB; // Next two levels
levelA = getRClevel(results, &offset, &used, RC6_T1);
levelB = getRClevel(results, &offset, &used, RC6_T1);
if ((levelA == MARK ) && (levelB == SPACE)) data = (data << 1) | 0 ;
else if ((levelA == SPACE) && (levelB == MARK )) data = (data << 1) | 1 ;
else return false ; // Error
}
// Success
results->bits = nbits;
results->value = data;
results->decode_type = RC6;
return true;
}
#endif

===========

in IRremoteInt.h - I found better results if I -1 the TICKS_LOW

#define TICKS_LOW(us) ((int)(((us)*LTOL/USECPERTICK - 1)))

Anonymous said...

Hi there,

I may not be using this library for things as complex as all of the other people here, but I need to use this library for a project at school. I was wondering if there is any way I could use this to send and receive data between two Arduino boards, we did not make the boards, they were pre-made. The board is a NICTA ed1 board, just looking that up should get you the board.

Thanks,
Caleb

P.S. Responses ASAP would be great, my teacher doesn't even know this stuff and told me to ask online.

Anonymous said...

Hello Ken,

Mostly I just want to thank you for your library here! **MUCH** appreciated.

I've gotten what I needed working - the ability to send the mute to the TV here when the Dot LED ring turns on and unmute when the LED ring turns off.

This was done for the same reason you did it, a friend with MS has a problem speaking loud enough to be heard over the TV, with this it should be easier for her as well as less frustrating.

I have this on a Uno and am considering doing it on a Micro, not much used in the grand scheme of things for a Uno, but then again, there are possibly other things that could be implemented that would help Jean. At least I think it can be done on a Micro :).

Again Sir, THANKS FOR YOUR EFFORTS!!!!!!!!!!!!

Javier said...
This comment has been removed by the author.
Javier said...
This comment has been removed by the author.
Javier said...

Thanks a lot for your contribution to the Arduino world.
I found that two of my controllers were not properly detected, after reading some posts and Ken's answer, I was able to properly capture the codes by increasing the RAWBUF to 256 in IRremote.h, and also the _GAP to 15000 in IRremoteInt.h.
Analyzing the codes, I noticed the total count of marks and spaces was 199 for one controller, and in the second controller there were spaces with a count of 9400, and the pattern was repeated after this long space.
Hope this help some of you facing same problems.

Unknown said...

HI EVERYONE
i have problem with reading data from taop1838
I generate a pulse 38KHz for trans Led
here my code
#define ledphat 3
#define ledthu A4
boolean led=0;
void setup(){
Serial.begin(9600);
pinMode(ledphat, OUTPUT);
pinMode(ledthu, INPUT);
cli();//stop interrupts

//set timer2 interrupt at 8kHz
TCCR2A = 0;// set entire TCCR2A register to 0
TCCR2B = 0;// same for TCCR2B
TCNT2 = 0;//initialize counter value to 0
// set compare match register for 8khz increments
OCR2A = 210;// = (16*10^6) / (76000) - 1 (must be <256)
// turn on CTC mode
TCCR2A |= (1 << WGM21);
// Set CS21 bit for 8 prescaler
TCCR2B |= (1 << CS20);
// enable timer compare interrupt
TIMSK2 |= (1 << OCIE2A);


sei();//allow interrupts

}//end setup

ISR(TIMER2_COMPA_vect){//timer1 interrupt 8kHz toggles pin 9
//generates pulse wave of frequency 8kHz/2 = 4kHz (takes two cycles for full wave- toggle high then toggle low)
if (led){
digitalWrite(ledphat,HIGH);
led = 0;
}
else{
digitalWrite(ledphat,LOW);
led = 1;
}
// delay(90);
}
void loop(){
if(ledthu == LOW)
{
Serial.println("co vat can");
// if(ledthu==HIGH)
// {
// delay(20);
// }
}
// else
// {
// Serial.print("a ");
// Serial.println("khong co vat can");
//}
}
everyone can guide me??

Unknown said...

Hi, i'm having problems to decode the air conditioner "komeco"(https://http2.mlstatic.com/controle-ar-condicionado-komeco-zhkz-01-original-pilhas-D_NQ_NP_927325-MLB25426377746_032017-F.jpg).
every time i tried to take the code, i got a different code, and don't work.
can someone help me?
i get this, and it's said the encoding is unknown
Encoding : UNKNOWN
Code : 9C370F01 (32 bits)
Timing[197]:
+6100, -7250 + 600, - 550 + 550, - 550 + 550, - 500
+ 600, - 500 + 600, - 500 + 550, - 550 + 550, - 550
+ 500, - 550 + 600, - 550 + 450, - 600 + 600, - 500
+ 550, - 550 + 550, - 500 + 600, - 500 + 550, - 550
+ 550, - 550 + 500, - 600 + 550, - 550 + 550, - 500
+ 600, - 500 + 550, - 550 + 600, - 500 + 550, - 500
+ 600, - 500 + 600, - 550 + 550, - 500 + 600, - 500
+ 550, - 550 + 550, - 550 + 550, - 500 + 600, - 500
+ 500, - 600 + 550, - 550 + 550, - 550 + 550, - 550
+ 500, - 550 + 600, - 500 + 550, - 550 + 550, - 500
+ 600, - 500 + 550, - 550 + 600, - 500 + 550, - 550
+ 600, - 500 + 500, - 600 + 550, - 550 + 550, - 500
+ 600, - 500 + 550, - 550 + 600, - 500 + 550, - 550
+ 550, - 500 + 600, - 500 + 550, - 550 + 550, - 550
+ 500, - 550 + 600, - 550 + 500, -1650 + 500, -1650
+ 550, - 500 + 600, - 500 + 550, -1600 + 550, -1600
+ 550, - 550 + 450, - 650 + 550, - 550 + 500, - 550
+ 600, - 500 + 500, - 600 + 550, - 550 + 550, - 500
+ 600, - 500 + 550, -1650 + 550, -1550 + 600, -1550
+ 600, - 500 + 500, - 600 + 550, -1600 + 550, - 550
+ 550, - 500 + 550, -1650 + 550, - 500 + 600, -1550
+ 550, - 550 + 550, - 550 + 550, -1600 + 550, - 550
+ 500, -1600 + 550, - 600 + 550, -1550 + 600, - 550
+ 500, - 550 + 550, -1600 + 500, -1650 + 500, - 550
+ 600, - 500 + 550, -7300 + 600
unsigned int rawData[197] = {6100,7250, 600,550, 550,550, 550,500, 600,500, 600,500, 550,550, 550,550, 500,550, 600,550, 450,600, 600,500, 550,550, 550,500, 600,500, 550,550, 550,550, 500,600, 550,550, 550,500, 600,500, 550,550, 600,500, 550,500, 600,500, 600,550, 550,500, 600,500, 550,550, 550,550, 550,500, 600,500, 500,600, 550,550, 550,550, 550,550, 500,550, 600,500, 550,550, 550,500, 600,500, 550,550, 600,500, 550,550, 600,500, 500,600, 550,550, 550,500, 600,500, 550,550, 600,500, 550,550, 550,500, 600,500, 550,550, 550,550, 500,550, 600,550, 500,1650, 500,1650, 550,500, 600,500, 550,1600, 550,1600, 550,550, 450,650, 550,550, 500,550, 600,500, 500,600, 550,550, 550,500, 600,500, 550,1650, 550,1550, 600,1550, 600,500, 500,600, 550,1600, 550,550, 550,500, 550,1650, 550,500, 600,1550, 550,550, 550,550, 550,1600, 550,550, 500,1600, 550,600, 550,1550, 600,550, 500,550, 550,1600, 500,1650, 500,550, 600,500, 550,7300, 600}; // UNKNOWN 9C370F01

Ian Castleton said...

In reply to simonjtaylor212: "Be wary of laptop IR!"

I am only just reading this article in 2017, but I remember back in the late 90's many of my laptops and mobile phones were equipped with an IR port, and used a protocol called irDA. This protocol looks more sophisticated than the protocol used on IR remotes. Modern day laptops with IR ports may still be using a variation on irDA, which may explain why the data could not be decoded by this Arduino project and appeared random. --ian




Unknown said...

Ken,
I have troubles with reading serial input from a digital temperature-sensor every time I start IR by irrecv.enableIRIn(). The sensor doesn't have to send data more often than maybe every minute so the easyest way to get rid of this effect would be to disable IR during the measurements (which only take milliseconds). Is it possible to disable IRIn? I searched a lot of examples and documents but couldn't find any command like disableIRIn() or something like that.
Thanks for any suggestions!
I don't like to sit in a room with a temperature reading 923°C any more :-)

Ken Shirriff said...

Dieter: There's currently no support for disabling the interrupts. You could look at enableIRIn() in irRecv.cpp, and make a disableIRIn() function that undoes these things. (Probably TIMER_DISABLE_INTR is all you need.) Alternatively, you could open an issue on the github and someone might implement it.

Unknown said...

Ken,
thank you very much for the really quick response! Due to the fact that the code doesn't have to be efficient or react quickly it seems to be enough to disable timer counter 2 in main loop and re-enable it after conversion. At least for testing it's fine, I will search for a more suffisticated solution later.
Thanks!

Unknown said...

How to translate. philips RC5 or RC6 codes to HEX? I found some codes like: 0.012 for Power. http://www.supportforum.philips.com/en/attachment.php?attachmentid=2492&d=1397042418

Onece I decode it by IR receiver i get:
C
RC6
C
RC6
1000C
RC6

Unknown said...

this is a great library sir, i want to control my AC lloyd .it has samsung protocol.i did a project using nec protocols and this library its work fine but using samsung protocol i didn't control it. i got the raw data using ir receiver
Encoding : SAMSUNG
Code : B24D7B84 (32 bits)
Timing[99]:
+4400, -4300 + 600, -1600 + 550, - 500 + 600, -1600
+ 550, -1600 + 550, - 550 + 550, - 500 + 600, -1550
+ 600, - 500 + 600, - 500 + 550, -1600 + 600, - 500
+ 550, - 550 + 550, -1600 + 550, -1600 + 550, - 550
+ 550, -1600 + 600, - 500 + 550, -1600 + 550, -1600
+ 600, -1600 + 550, -1600 + 550, - 550 + 550, -1600
+ 550, -1600 + 600, -1550 + 600, - 500 + 600, - 500
+ 550, - 550 + 550, - 500 + 600, -1550 + 600, - 500
+ 600, - 500 + 550, -1600 + 600, -1550 + 600, -1600
+ 550, - 500 + 600, - 500 + 550, - 550 + 550, - 550
+ 550, - 500 + 600, - 500 + 550, - 550 + 550, - 500
+ 600, -1600 + 550, -1600 + 550, -1600 + 550, -1600
+ 600, -1600 + 550
unsigned int rawData[99] = {4400,4300, 600,1600, 550,500, 600,1600, 550,1600, 550,550, 550,500, 600,1550, 600,500, 600,500, 550,1600, 600,500, 550,550, 550,1600, 550,1600, 550,550, 550,1600, 600,500, 550,1600, 550,1600, 600,1600, 550,1600, 550,550, 550,1600, 550,1600, 600,1550, 600,500, 600,500, 550,550, 550,500, 600,1550, 600,500, 600,500, 550,1600, 600,1550, 600,1600, 550,500, 600,500, 550,550, 550,550, 550,500, 600,500, 550,550, 550,500, 600,1600, 550,1600, 550,1600, 550,1600, 600,1600, 550}; // SAMSUNG B24D7B84
unsigned int data = 0xB24D7B84;

Encoding : SAMSUNG
Code : B24D1FE0 (32 bits)
Timing[99]:
+4400, -4300 + 600, -1600 + 550, - 500 + 600, -1600
+ 550, -1600 + 550, - 550 + 550, - 500 + 600, -1550
+ 600, - 500 + 600, - 500 + 550, -1600 + 600, - 500
+ 550, - 550 + 550, -1600 + 550, -1600 + 550, - 550
+ 550, -1600 + 600, - 500 + 550, - 550 + 550, - 500
+ 600, -1600 + 550, -1600 + 550, -1600 + 550, -1600
+ 600, -1600 + 550, -1600 + 550, -1600 + 600, -1550
+ 600, - 500 + 550, - 550 + 550, - 500 + 600, - 500
+ 550, - 550 + 550, - 550 + 550, -1600 + 550, -1600
+ 600, -1550 + 600, -1600 + 550, - 500 + 600, - 500
+ 550, - 550 + 550, -1600 + 550, - 550 + 550, - 500
+ 600, - 500 + 600, - 500 + 550, -1600 + 550, -1600
+ 600, -1600 + 550
unsigned int rawData[99] = {4400,4300, 600,1600, 550,500, 600,1600, 550,1600, 550,550, 550,500, 600,1550, 600,500, 600,500, 550,1600, 600,500, 550,550, 550,1600, 550,1600, 550,550, 550,1600, 600,500, 550,550, 550,500, 600,1600, 550,1600, 550,1600, 550,1600, 600,1600, 550,1600, 550,1600, 600,1550, 600,500, 550,550, 550,500, 600,500, 550,550, 550,550, 550,1600, 550,1600, 600,1550, 600,1600, 550,500, 600,500, 550,550, 550,1600, 550,550, 550,500, 600,500, 600,500, 550,1600, 550,1600, 600,1600, 550}; // SAMSUNG B24D1FE0
unsigned int data = 0xB24D1FE0;
how can i control my AC any one help would be appreciated.
thank you

Anonymous said...

how use more than one ir led

Unknown said...

great work !!!!!
how can i use this library for atmega8
please help...

daniel said...

I've been given this info for a device. I'm trying to get it to work but i am a beginner with arduino and have absolutely no idea where I'm going wrong is there any chance someone on here might be able to wright a basic script for me to help me understand it a bit better?

|"To enter this mode a 3 sequence RC5 IR command must be sent within 1.5secs of first command to last command.

The sequence will be based on [system code] [command code]:
[21] [102]
[21][112]
[21][122]

Note – the field bit is used to give 7bit command code. See Philips RC5 protocol spec. "

thanks
dan

Lukasz S. said...

How to fix interrupt error?

IRremote.cpp:28:27: fatal error: avr/interrupt.h: No such file or directory

#include

tawzeeef said...

Hi all , r there any youtube video about this specific experiment ...I mean one step learning remote controls ?!!!

Jesus Corona said...

Hi, I've been looking for a long time and I've been working too hard trying to get the IR codes from my split type air conditioner remote control without success. It brand is Parker and I can't get that codes because no one sketch can decode them, therefore recently I got a sketch it could get some codes but, they are repeated in most of the buttons of the remote. So, if you can give me your e-mail, I could send to you some pictures of the remote and arduino serial monitor screenshots. How can get the raw codes to convert them to any useful codes in order to control my appliance from arduino?. I hope you can help me and I'll be really grateful about that.

Unknown said...

Hello! Thank you so much for your help. IRemote lib doesnt work for me but your code does but I have problem sending my codes. I tried using your receive code and it works fine with my 48 bit remote. Problem is I cant send the codes back. How do I send the pulses with 50% duty cycle 38Khz signals?

Unknown said...

Hey, absolute noob here, are there any detailed instructions on assembling this?

Unknown said...

Olá Ken,
Gostaria de saber se é possível adicionar mais um LED infravermelho em uma porta PWM, para que possa gerenciar dois ar-condicionado simultaneamente.

Unknown said...

hi I am using Arduino ide for programming and completed many projects in Arduino it also includes Infrared. Now I am migrated to stm32F103c8 using Arduino ide then I want to use this infrared Arduino library for STM32 but its not working and returns error what changes in the library may I use to work with STM32 ??


Please anybody Help

Unknown said...

Excuse me sir, My name is Beni. Can i get Daikin remote library please, my arduino lib need this IR library soon. Thanks for the replies

Joe T. said...

Thank you for the info. Question: I have a remote for my Pentax Camera. Pentax protocol is a 13ms burst, a 3ms pause, then 7 burst cycles of 1ms on and 1 ms off. It is at a frequency of 38Khz and 50% duty cycle. Using your library and the Arduino, it show a code of 8DCDAE60 for the shutter. Looking at the signal of an AX-1838-HS sensor, and the raw of the remote on an Oscilloscope, it matches the protocol above. Where does the code come from? This has been driving me nuts for a month or two. All my other remotes, the signal on the Scope decodes to what the Arduino sees.

Thanks, Joe

Joe T. said...

After finding out that Unknown send an arbitrary HEX code, used IRrecvdumv2 and used the info to irsend.sendRaw and it worked like a charm.

Thank you for the great code.

Joe

Karanbir said...

I am using this library for controlling with a NEC remote.
I will be using the up key(0xFF48B7), the down key(0xFF609F) and the enter key(0xFFAA55) in the Arduino IDE.

How do I code to check which key is pressed.
If enter key is pressed led on pin 7,
if up key is pressed the count displayed on a seven segment digit is to be incremented, and with the down key the count is to be decremented.
I have written a case code with direct port manipulation.
Can you suggest a method of discrimination for this three keys pressed?

Karanbir said...

Hi!
Got this part of my code working, must say the IRremote library is great.
Next I have to implement phase angle control with zero cross and control the output with remote in steps 0 to 9. This is my small project of using Atmega 8 to control speed of fan with IR remote.
Regards.

Karanbir said...

Which timer does your library use?

wounder said...

I have an IR remote for a gadget, I am decoding the values using esp8266 Arduino library

i get,

Protocol: UNKNOWN

Code : 0xD8396229 (129 Bits)

uint16_t rawData[257] = { 536, 966, 544, 462, 506, 998, 512, 490, 516, 488, 544, 962, 514, 490, 516, 988, 514, 490, 512, 972, 530, 476, 530, 972, 510, 996, 514, 492, 512, 974, 532, 492, 512, 492, 510, 494, 510, 492, 544, 462, 506, 498, 528, 478, 530, 496, 510, 494, 508, 494, 508, 496, 544, 462, 524, 480, 526, 480, 526, 498, 508, 496, 506, 496, 508, 496, 544, 462, 542, 464, 524, 480, 526, 498, 506, 498, 506, 498, 508, 496, 540, 466, 542, 462, 522, 482, 524, 482, 524, 498, 504, 500, 504, 500, 504, 500, 542, 962, 506, 980, 526, 484, 520, 500, 504, 500, 504, 500, 506, 500, 542, 462, 546, 460, 546, 460, 522, 502, 502, 500, 504, 502, 502, 502, 508, 498, 544, 462, 544, 460, 546, 954, 542, 464, 544, 462, 546, 460, 562, 484, 504, 478, 526, 478, 526, 478, 504, 500, 542, 464, 546, 460, 544, 478, 526, 478, 526, 478, 526, 478, 504, 500, 540, 466, 542, 464, 546, 460, 544, 478, 526, 478, 526, 478, 526, 480, 506, 500, 540, 466, 544, 462, 544, 478, 526, 478, 526, 478, 526, 478, 502, 502, 506, 498, 540, 466, 544, 462, 544, 478, 526, 478, 526, 478, 526, 478, 504, 502, 538, 466, 542, 464, 544, 462, 542, 478, 526, 478, 526, 478, 526, 478, 506, 500, 538, 466, 544, 462, 542, 480, 524, 480, 524, 480, 524, 480, 504, 502, 506, 498, 540, 466, 544, 464, 542, 958, 508, 500, 544, 462, 542, 480, 524, 480, 524, 480, 524}; // UNKNOWN D8396229

the same "raw data" is sent to gadget using an IR transmitter LED, its receive well.

but when i send the hex code(0xD8396229) using different


Why IR receiver at gadget not take the hex code?
protocol defines in the library(ESP8266IRremote-master), it does not work. Why does this happen?

protocol tested,

irsend.sendNEC(0x00D8396229);

irsend.sendSony(0x00D8396229, 129, 2);

How can I solve this issue?

tjjly said...

Ken, don't know if you're still reading these posts or not. For an IR project, I'm using an IRreceive code naming manufacturers and I get this message on several: "(name) not declared in this scope." When I delete that section it reads until it finds another (about 5 total). Problem is one of them is Denon, which I want. Is there an updated library that may work better or do I have a different problem?

Unknown said...

I want to generate infrared signal using arduino to control digital echo JBL KX180. The manufacturer has given the function keys code at https://www.manualslib.com/manual/1321717/Jbl-Kx180.html?page=12#manual but I do not know which library to use? how to write code? hope the community helps. Thanks!

Anonymous said...

I don't seem to be able to get past trying to load the IRRemote library without error.
This is my sketch, and following is the error message;
#include

int RECV_PIN = 11;
IRrecv irrecv(RECV_PIN);
decode_results results;

void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
irrecv.enableIRIn();

}

void loop() {
// put your main code here, to run repeatedly:
if (irrecv.decode(&results)){
Serial.println(results.value, HEX);
irrecv.resume();
}
}

Error message;
Arduino: 1.6.5 (Windows 7), Board: "Arduino/Genuino Uno"

C:\Program Files (x86)\Arduino\libraries\RobotIRremote\src\IRremoteTools.cpp:5:16: error: 'TKD2' was not declared in this scope
int RECV_PIN = TKD2; // the pin the IR receiver is connected to
^
Multiple libraries were found for "IRremote.h"

Used: C:\Program Files (x86)\Arduino\libraries\RobotIRremote

Not used: C:\Users\John\Documents\Arduino\libraries\Arduino-IRremote-stable

Not used: C:\Users\John\Documents\Arduino\libraries\Arduino-IRremote-2.7.0

Not used: C:\Users\John\Documents\Arduino\libraries\Arduino-IRremote-master

Error compiling.

This report would have more information with
"Show verbose output during compilation"
enabled in File > Preferences.

Hany Naeem said...

Hello

I am just a beginner programer and need guidance.

I have successfully built an IR remote using arduino Nano to control my T.V with 15 buttons.

My issue is it possible to control different appliances such as (A.C, Subwoofer, Fan, another T.V ...etc) with the same remote that I built?

I mean as example if mode 1 selected, then I can control the tv using the 15 buttons, if mode 2 selected, I can use the Subwoofer with the 15 buttons, if mode 3 selected .. etc.

Like the universal remote.

I do think it's a coding issue, and my programming skills are very basic, so is there anyone successfully made this project can share the code with me?

Thank you so much.

Yakman said...

I'm using the Sparkfun page to implement your code. So far, no workie. The baud rate at Sparkfun is 9600, but in your code it's 115000. Also, the input pin in their drawing is digital 11, but in your code (way down at the end of the #ifelse's in the PinDefinitionsAndMore.h) it's pin 2.

I don't think the loop() is running because it is stuck in the IrReceiver.decode() call.

What gives? Thanks.

My signin email below is screwed up. Can you reply to [email protected]?

«Oldest ‹Older   801 – 896 of 896   Newer› Newest»