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.

895 comments:

«Oldest   ‹Older   601 – 800 of 895   Newer›   Newest»
Unknown said...

Hi Ken! Thanks a lot for sharing this stuff. I very appreciate it!

I have some kind of troubles when I want to make an IR-tele commanded car: I must use two PWM's pins for the motors and another one for the IR reciever.

I have made two versions of my code. In one of them, I initialize with irrecv.enableIRIn(); in the void setup() part. The decode is well done only once. All the rest of the time it marks FFFFFFFF.

In the other version of code, I call irrecv.enableIRIn(); every time after the move command to the motors has been made. In this case the decode of the IR beam it's ok, but the motors don't move properly...

Would you so kind to tell us if the 'analogWrite' function over a PWM pin is compatible with an IR receiver?

Thanks in advance for your help.

Granada, Spain

Unknown said...

I want to do IR communication between two robots using arduino.IR led on one robot and TSOOP 1738 ir receiver on the other robot.
I want send certain encoded signal similar to sony remote control codes using sendsony function and then TSOP 1738 will receive it and then decode it and then appropriate action will be taken by another robot.
Please tell me the connection for TSOP1738..also initially i will mount both led and tsop on one arduino board.I am not going to use remote control.i will send code directly in the program.
My email ID:[email protected]

AnalysIR said...

Hi Guys

We have just launched a Crowdfunding campaign on IndieGoGo for AnalysIR - IR Decoder & Analyzer. Currently we support 17 IR protocols and are looking for more to add as part of the campaign. Suggestions Welcome!

You can find out more about it on Campaign or Screenshot via www.AnalysIR.com

Anonymous said...

Hello
Please help me with your advice.
I have a arduino mega 2560 (clone from ebay) and an ir transmitter shield (from ebay too please see the bottom link).
I connected it on digital pin 3 (after this I tried on analog plin 3) and I use the library from this site.
I tried to see if it works or if it transmit something with a camera from my pfhone(I knew the phone camera detect the light of ir leds), but I don't see anything.

Can you please help me.Many thanks

http://www.ebay.com/itm/IR-Transmitter-Module/170880097101?_trksid=p2045573.m2102&_trkparms=aid%3D222004%26algo%3DSIC.NEO%26ao%3D1%26asc%3D15429%26meid%3D8908337748359352324%26pid%3D100034%26prg%3D7406%26rk%3D5%26#ht_2813wt_905

Anonymous said...

Hi Shirriff, thanks a lot for such wonderful blog. Like you explain above for reconnnn's questions that how to send IR code for lg tv which having 16 bits pre_data. There are so many others use cases also. Where in some files toggle_bit is present.ptrail, repeat is there do we need to take care of that while sending ? also is that pin 3 is common for sending all IR codes or there may be diff pins we have to used for diff brands IR codes ?
Please clear my doubts.
Thanks,
manendra

Anonymous said...

Hi Shirriff, thanks a lot for such wonderful blog. Like you explain above for reconnnn's questions that how to send IR code for lg tv which having 16 bits pre_data. There are so many others use cases also. Where in some files toggle_bit is present.ptrail, repeat is there do we need to take care of that while sending ? also is that pin 3 is common for sending all IR codes or there may be diff pins we have to used for diff brands IR codes ?
Please clear my doubts.
Thanks,
manendra

Anonymous said...

Hi Shirriff, thanks a lot for such wonderful blog. Like you explain above for reconnnn's questions that how to send IR code for lg tv which having 16 bits pre_data. There are so many others use cases also. Where in some files toggle_bit is present.ptrail, repeat is there do we need to take care of that while sending ? also is that pin 3 is common for sending all IR codes or there may be diff pins we have to used for diff brands IR codes ?
Please clear my doubts.
Thanks,
mandy

Anonymous said...

Hi Shirriff, thanks a lot for such wonderful blog. Like you explain above for reconnnn's questions that how to send IR code for lg tv which having 16 bits pre_data. There are so many others use cases also. Where in some files toggle_bit is present.ptrail, repeat is there do we need to take care of that while sending ? also is that pin 3 is common for sending all IR codes or there may be diff pins we have to used for diff brands IR codes ?
Please clear my doubts.

Thanks,
Mandy

Anonymous said...

Hi Shirriff, thanks a lot for such wonderful blog. Like you explain above for reconnnn's questions that how to send IR code for lg tv which having 16 bits pre_data. There are so many others use cases also. Where in some files toggle_bit is present.ptrail, repeat is there do we need to take care of that while sending ? also is that pin 3 is common for sending all IR codes or there may be diff pins we have to used for diff brands IR codes ?
Please clear my doubts.
Thanks,
manendra

Anonymous said...

Hi Shirriff, thanks a lot for such wonderful blog. Like you explain above for reconnnn's questions that how to send IR code for lg tv which having 16 bits pre_data. There are so many others use cases also. Where in some files toggle_bit is present.ptrail, repeat is there do we need to take care of that while sending ? also is that pin 3 is common for sending all IR codes or there may be diff pins we have to used for diff brands IR codes ?
Please clear my doubts.
Thanks,
manendra

Anonymous said...

Hi Shirriff, thanks a lot for such wonderful blog. Like you explain above for reconnnn's questions that how to send IR code for lg tv which having 16 bits pre_data. There are so many others use cases also. Where in some files toggle_bit is present.ptrail, repeat is there do we need to take care of that while sending ? also is that pin 3 is common for sending all IR codes or there may be diff pins we have to used for diff brands IR codes ?
Please clear my doubts.
Thanks,
manendra

Unknown said...

Thanks for your library.
If someone is interested in the code to start a LG hombot:

#include
unsigned int LGHombotStartcode[] = {400, 1600, 400, 600, 400, 1550, 400, 1600, 400, 600, 400, 1550, 400, 600, 400, 600, 400, 600, 400, 600, 400, 1600, 400, 1550, 400};


IRsend irsend;

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

void loop() {
if (Serial.read() != -1) {

irsend.sendRaw(LGHombotStartcode, 25, 38);

}
}

Nataraja G said...

even if I press the same key on my IR remote ( samsung ) , each time I'm getting different raw codes !@?

did someone get this problem ?

csnb said...

Ken,
Thanks for taking the time to compile the data for the library and share it with others.

Question, how would I use an IR remote for momentarily switching? For example pressing an remote button makes a motor run forward only as long as it's pressed and turn off when not pressed? Sorry if this is a duplicate question.

Anonymous said...

csnb: Each remote is different. You need to figure out what YOUR remote does when you keep the key pressed. It may also differ based on which key it is.
Good Luck!

Satheesh said...

My decoded Dump for NEC is
1FE48B7
Decoded NEC: 1FE48B7 (32 bits)
Raw (68): -7604 8900 -4400 600 -500 600 -550 550 -550 600 -500 600 -500 600 -550 550 -550 600 -1650 550 -1650 550 -1650 600 -1650 600 -1650 550 -1650 600 -1650 550 -1650 600 -500 600 -550 600 -1600 600 -500 600 -500 650 -1600 600 -500 600 -500 600 -550 600 -1600 600 -500 600 -1650 600 -1600 600 -550 600 -1600 600 -1650 600 -1600 600
1FE807F
Decoded NEC: 1FE807F (32 bits)
Raw (68): -32408 8800 -4500 550 -550 550 -550 600 -550 500 -600 550 -550 550 -550 550 -550 550 -1650 600 -1650 600 -1650 600 -1650 500 -1700 550 -1700 550 -1650 600 -1650 550 -550 550 -1650 600 -550 550 -550 550 -550 550 -550 550 -600 550 -550 550 -550 550 -550 550 -1700 550 -1650 550 -1700 550 -1650 600 -1650 550 -1700 550 -1650 550
1FE40BF
Decoded NEC: 1FE40BF (32 bits)
Raw (68): -7716 8850 -4450 550 -550 600 -550 600 -500 550 -550 600 -500 600 -500 600 -500 600 -1650 600 -1650 550 -1650 550 -1700 550 -1650 600 -1650 600 -1600 600 -1650 600 -500 600 -500 600 -1650 550 -550 600 -500 600 -550 550 -550 550 -550 550 -550 600 -1650 600 -500 550 -1650 600 -1650 600 -1650 550 -1650 600 -1650 550 -1650 600
1FE50AF
Decoded NEC: 1FE50AF (32 bits)
Raw (68): 31658 8850 -4400 650 -500 600 -550 550 -550 550 -550 550 -550 600 -500 600 -500 600 -1650 600 -1650 550 -1650 600 -1650 550 -1650 550 -1700 550 -1650 600 -1650 600 -500 600 -500 600 -1650 600 -500 600 -1650 550 -500 600 -550 600 -500 600 -500 600 -1650 550 -550 600 -1650 550 -550 550 -1650 600 -1650 600 -1650 550 -1650 600
1FED827
Decoded NEC: 1FED827 (32 bits)
Raw (68): -12492 8850 -4450 550 -550 600 -550 550 -550 550 -550 550 -550 550 -550 550 -550 600 -1650 600 -1650 550 -1700 500 -1700 550 -1650 600 -1650 550 -1650 600 -1650 550 -550 550 -1700 550 -1650 600 -550 550 -1650 600 -1600 600 -550 550 -550 600 -500 600 -500 600 -550 550 -1650 600 -500 600 -550 550 -1650 600 -1650 600 -1600 600
1FEF807
Decoded NEC: 1FEF807 (32 bits)
Raw (68): 1370 8850 -4450 600 -500 550 -600 550 -500 550 -600 550 -550 550 -550 600 -500 600 -1650 550 -1700 550 -1650 600 -1650 550 -1700 500 -1700 550 -1650 600 -1650 550 -550 600 -1650 550 -1650 600 -1650 550 -1700 550 -1650 550 -600 550 -500 600 -550 550 -550 550 -550 550 -550 550 -600 550 -550 550 -1700 500 -1700 550 -1650 600


But when i try receive program
i am getting
1FE50AF
FFFFFFFF
1FE50AF
FFFFFFFF
1FED827
FFFFFFFF
1FEF807
FFFFFFFF
1FE30CF
FFFFFFFF

what if the FFFFFFF means when i long press the button it shows only FFFFFFF

and another doubt is i want to control my robot with the code i receive form the remote,..can you help me in the programming

Unknown said...

Sateesh
The FFFFFFFF NEC sequence is just the NEC repeat code. So when you press a key you get the original code and if you keep it pressed you will only get FFFFFFFF.

So unless you need it for things like VOL+ or VOL- you can usually ignore any FFFFFFFF in your code.

Good news is that it is working


==============================================
Support our AnalysIR Project on bit.ly/1b7oZXH

waichal chaitanya said...

Hi ken.This is an awesome library and it works for all buttons on my tv remote except the On/Off button.
I use the doc here: goo.gl/lhCid for generating and sending raw codes.
I seem to get different codes everytime.If i use one of the raw code it works but not all times.. sometimes it does and at other times it just doesnt!! Help me please!!

mbrfix said...

Hi Ken,
I try to imitate LG air conditioner remote control 6711A90032Y. With your perfect example code, I decoded all the functions of the remote and got the hex codes. But when I send them to the air cond., it didint respond. This is the close button with my receiver: http://www.bariskonag.com/problem.png
The only difference I see is Raw(60) and Raw(36). Original remote keeps oscilating. May it be the reason? How can I do the same? Or do you think there is another problem?
Thank you

kwalker said...

Does anyone know what it would take to get this library working with the Sparkfun Pro Micro 5V/16MHz?

kwalker said...

Regarding my previous question, after a large amount of trial and error, I managed to get sending to work with the Sparkfun Pro Micro by using timer 3 and PWM pin 5. (Receiving IR codes worked without any modification of the IRremote code.)

Great library, by the way.

JoeO said...

kwalker: Good work modifying the code to work. Please publish your changes here so that others can use it or they will know what they have to modify to get their code to work on another version of the Arduino.... Thanks

ROBERSON said...

And for TV SEMP TOSHIBA witch libary use or code?

Gokhan Onal said...

this works great for me. On the other hand, i am looking for possibility to work with two IR Led to control two devices located in different places. As we cannot set irsend pin, I could not realise. Is it possible?

Thanks in advance
Gokhan

kwalker said...

JoeO: My code modifications are a sloppy hack, so I don't want to post them verbatim here. But here's the essential idea. In IRremoteInt.h there are a lot of preprocessor directives whose goal is to select a timer and PWM pin which are appropriate for the board one is using. For the Sparkfun Pro Micro 5V/16MHz, timer 3 and PWM pin 5 seem to do the trick. Rather than modify the preprocessor stuff to make the right decision, I just extracted the parts of IRremoteInt.h that dealt with timer 3 and set the PWM pin to 5. If someone can tell me how to detect that the board is the Sparkfun Pro Micro, then I could try modifying IRremoteInt.h so that it works for that board too.

Lauszus said...

@kwalker
You could simply replace this line with:

#elif defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__) || defined(__AVR_ATmega32U4__)

Then you could simply add a comment to people telling them to uncomment the following line, if they are using the Pro Micro as pin 13 is not broken out on the board.

Also you could add support for timer1 if you added this:

#elif defined(__AVR_ATmega32U4__)
#define TIMER_PWM_PIN 9 /* Leonardo or Pro Micro */

After this line.

Do you want me to send open up a pull request at Github for you?

Regards
Lauszus

Marjan Mrak said...

Looks like it's not working in arduino ide 1.0.5.

I won't import as arduino-irremote-master. I changed name to irremote. I was able to import it, but I was not able to build first two examples.

Peter Scargill said...

Lovely - but I have a question.. if you look at most of the transmit routines - you call the routine with a code - and a length - I cannot see the length defined - and when reading values from an IR received I see a code - but not a length to plug in once I want to retransmit something...
??

Gert3d said...

I have recorded the code for (volume up) using a Pioneer remote for the model VX527, he result is:
Received NEC: A55A50AF
I am not sure how to use this result for sending (anyone?), therefore I also recorded the raw code, the result is quite consistent. When sending this raw code and recording it with a second Arduino, I indeed receive the same code again.
However, my VX527 is not impressed: no response, not even when being in very close proximity.
Is it possible that the library routine misses vital information?

gert3d said...

I further tested all my equipment, and only the Samsung TV responds correctly when using the IRrecord sketch.
There wll be code's recorded from the remotes of my Pioneer receiver, the Sony blu ray player and the Motorola iTV receiver, but when sent out again by Arduino, these have no effect.
My conclusion: the IR remote library would need updates for such purposes ...

Unknown said...
This comment has been removed by the author.
Ecegmu said...

Hi Ken,
I want to send a signal back to the IR sender to stop the transmission. How do I stop it ?
Thanks

Unknown said...

Hi friend... i tried to use this library with my Samsung Smart TV and with my Home Theater... i'm using the example on the Arduino to rec and repeat command. When I read a IR Code of my Home Theater, Arduino return a RAW code and when I repeat the command, it works but when I use my remote control of Samsung TV, it returns a Samsung code but can't repeat command. I using a Samsung code I can't see IR Led blinking to send command, only with RAW code (Home Theater). Do I something wrong?

Unknown said...

Solved... Add code:
else if (codeType == SAMSUNG){
irsend.sendSamsung
....
}

Ajax said...

Hai Ken great work with your IR remote library, i have done a similar universal remote project using your library. But my only problem is that my ir led works only for a 4-5 feet of distance. can you suggest some ir leds that has a range of 10-15 feet and also which has a wide angle.

I have seen a few ir leds from osram, vishay , and sharp. are they good.

pls suggest.

thanks in advance
-- Ajay Pyaraka

Ken Shirriff said...

Hi Ajay! I don't have any specific LEDs to recommend. Are you using a transistor to boost the power? That's likely to make a big difference.

Unknown said...

Hi Ken, Could I use two different timer (2,3) on the Mega2560 to receive IR signal simultaneously from two IR Receiver?

Anonymous said...

Alex Doan - Your problem is going to be that an IR receiver will get confused by 2 IR transmitters sending signals at the same time.

®¿® said...

For those that wanted the Sharp TV Remote decode (Remote Used: LCDTV - GA667WJSA), see below:

long IRrecv::decodeSharp(decode_result_type *results) {
long data = 0;
int offset = 1; //Skip the first long space

// Check raw bit length, should be 32 (15 mark bits + 16 space bits + 1 leading space bit)
if (_irparams.rawlen < 2 * SHARP_BITS + 2)
return ERR;

for (int i = 0; i < SHARP_BITS; i++) {

if (!MATCH_MARK(results->rawbuf[offset], SHARP_BIT_MARK)) {
return ERR;
}

offset++;

if (MATCH_SPACE(results->rawbuf[offset], SHARP_ONE_SPACE)) {
data = (data << 1) | 1;
}
else if (MATCH_SPACE(results->rawbuf[offset], SHARP_ZERO_SPACE)) {
data <<= 1;
}
else {
return ERR;
}
offset++;
}
// Success
results->bits = SHARP_BITS;
results->value = data;
results->decode_type = SHARP;

//Delay for USECPERTICK (50 ms) to skip next interrupt to avoid getting garbage (need to get the actual reason for this)
//If you double this value (USECPERTICK*2 = 100 ms), you won't get a duplicated IR code, but this may not be to SHARP IR protocol, so it seems
_delay_ms(USECPERTICK);

return DECODED;
}

Note: I used AVR Studio and the _delay_ms() call is from "util/delay.h", you can simply sub that for the Ardiuno Studio's version.

Note (2): There is a bug in the decodeSony(). When a duplicate is found, the code returns SANYO and not SONY for 'decode_type'

®¿® said...
This comment has been removed by the author.
®¿® said...

After additional testing and checking, it seems that the Sharp Remote sends a three code sequence per button push.
Example: Pressing '4' on the Sharp Remote sends code "0x00004082" in the following sequence:

======================================================
| HEX | Binary | Description
0x00004082 100000010000010 <== [First IR code received] - Actual Code
0x0000437D 100001101111101 <== [Second IR code received] - 10 least significant bits are flipped on actual code
0x00004082 100000010000010 <== [Third IR code received] - Actual Code

So it seems that logic can/should be implemented such that we compare the first received code with the second received code after the 10 least significant bits have been flipped on the second received code. If they match, then a good chance that the codes were sent correctly.
And for additional error checking, the third received code can be compared with the first and second (after the second has been flipped, of course).

gokhan said...

Hi,

I want to use irsend for 2 different ir led. Is it possible via this library?

Thanks in advance
Gokhan

Unknown said...

I really love this library. Make my life easier.

BTW it's very easy to change pin 3 IR output to pin 9 ... you just have to uncomment 1 line

// Arduino Duemilanove, Diecimila, LilyPad, Mini, Fio, etc
#else
#define IR_USE_TIMER1 // tx = pin 9
//#define IR_USE_TIMER2 // tx = pin 3
#endif

All in
IRremoteInt.h

Nick said...

If you have any spare time, could you implement the Lego PF protocol in your library?

http://www.philohome.com/pf/LEGO_Power_Functions_RC_v110.pdf

Nick said...
This comment has been removed by the author.
Anonymous said...

Hi there,
I'm having problems getting it to work with the enhanced ide 1.0.5 - I can compile just fine, but no data is ever being received... what could be wrong?

Anonymous said...

Your transmitter may not be transmitting. Look at the transmitter with a camera. You should see it blinking.
Your IR receiver may not be working.
You may be using a transmitter that the code does not support.
You may have a wiring error on the receiver.

Anonymous said...

Ahh...
I need to add some additioinal info - I have it running in a different project compiled with the 002 IDE.
And an old IR library.

I just wanted to clean the project, and use the new ide.

Anonymous said...

Hi,
I have an issue after having my Arduino powered on for a long time the IR-receiver is no longer receiving anything. That means decode function does not return 1 anymore. After Arduino reset (pressing reset button or power removal/insert) it's working again.

any idea? i'm getting crazy with this error :(

Andrew Ward said...

Yeah... Just loaded the same sketch in an Uno.. Works FINE... But it won't work on the Yun... Must be some kind of problem with the Yun's handling of Pin 3 for PWM output.

Suggestions anyone?

Thanks

Andrew Ward said...

Looks like my first post got dropped somewhere.... My problem is with the new Yun and the latest Library from Ken and latest Arduino IDE (1.5.4) will not transmit anything on pin 3.

Serial.println("Sending ON");
irsend.sendNEC(0xF7C03F, 32);

But, pin 3 never wiggles at all.

Same sketch works Fine on same breadbard plugged in to an Uno R3. But in the Yun... nothing.

IR Receive works fine... But Yun and Uno R3.

Lauszus said...

@Andrew Ward
Since the Yun uses the same microcontroller as the Leonardo: ATmega32U4. It uses pin 13 instead.

Regards
Lauszus

Unknown said...

HI every time i write the code in the serial monitor it sends the code one time and it's suposed to send it 3 times. what i should do?

Andrew Ward said...

@lauszus:

Thanks for the input.... Got it working on the Yun/Yún:

Had to un-comment / add to IRremoteInt.h

#define IR_USE_TIMER4_HS

and

#define CORE_OC4A_PIN 13


Now everything works fine.... Receiving on Pin 11.

Not sure where / how all this stuff lines up... (i.e. where it should be structured in the include files. And, what is tying it back to pin 11? Makes no real sense to me. But it works.

I wish there was more clarity and that the IRremoteInt.h had more structure / comments to it so one could know what to do. Or a web / blog page that presented it well.

Maybe this: ???
http://books.google.com/books?id=MK1cLf7u5IMC&lpg=PA236&dq=IR_USE_TIMER4_HS&pg=PA236#v=onepage&q=IR_USE_TIMER4_HS&f=false

Alejandro Mediavilla said...

Hi there, i was trying to build a small ir reciever/emitter with your example code but when i try to compile it my arduino uno tells my that "serial" is not declared n this scope, any help with tht?

Lauszus said...

@Andrew Ward
What version of the code are you using? The newest version can be found at Github: https://github.com/shirriff/Arduino-IRremote.
It got everything enabled by default, so there is no need to edit it - see: https://github.com/shirriff/Arduino-IRremote/blob/master/IRremoteInt.h.

You set the receive pin as an argument of the constructor for the instance - see: https://github.com/shirriff/Arduino-IRremote/blob/master/examples/IRrecord/IRrecord.ino#L20-L24. So that is why you use pin 11 for receiving and then pin 13 is used for sending data, as defined here: https://github.com/shirriff/Arduino-IRremote/blob/master/IRremoteInt.h#L374.

You should read this blog post about the timers on the Arduino: http://www.righto.com/2009/07/secrets-of-arduino-pwm.html if you want to know more about how it works.

Regards
Lauszus

The Tinkerer said...

Can I use Af motor lib from adafruit with this or does ardunio only able to run one pwm timer at a time.?can I time an interrupt or something to make em both work together.Or which timer to use.
Whew

Unknown said...

Hi. Congrats for this beautiful works. I am already using, works perfectly.
So, i have a full interface that i made using CommandFusion. In this interface all my codes are to use with a Global Cache device. The code is something link this:
sendir,4:3,1,38000,1,1,343,170,21,22,21,22,22,63,21,22,21,22,21,22,21,22,21,22,22,63,22,63,21,22,22,63,22,63,22,63,22,63,22,63,21,22,21,22,22,63,21,22,21,22,21,22,22,63,22,63,22,63,22,63,21,22,22,63,22,63,22,63,21,22,21,22,22,760
So...there is way to convert this code to a raw ir format ? Maybe using python or javascript ?
Very thanks for your help.

gokhan said...

Hello,

Thanks @Ken for the great library first. I can use it with Arduino UNO and MEGA very easily.

Also thanks to @Lauszus for good explanations about pins and timers.

I need to use 2 different IR Leds for devices in different rooms. Is it possible to drive to IR Led with this library.

Thanks in advance
Gokhan

Unknown said...

Hello Ken,

Thanks for you code! I have a question that I could not figure out myself.

If I use the IRrecieve example and press on the red teletext button of my Sony remote I recieve:

338
FFFFFFFF
FFFFFFFF
FFFFFFFF

To my opinion the 338 is correct but the 'FFFFFFFF' unexplainable

Jakabo27 said...

Is there an easy way to set up two IR lights, to send separate signals? (different directions)

VanceAnce said...

hy im no expert with programming but when i implement the library into c/.../arduino/.../libraries/IRr...

and just want to run an example i always get errors - just like this e.g.:

In file included from sketch_dec09a.ino:13:
C:\Program Files\Arduino\libraries\IRremote/IRremoteInt.h:87: error: 'uint8_t' does not name a type
C:\Program Files\Arduino\libraries\IRremote/IRremoteInt.h:88: error: 'uint8_t' does not name a type
C:\Program Files\Arduino\libraries\IRremote/IRremoteInt.h:89: error: 'uint8_t' does not name a type
C:\Program Files\Arduino\libraries\IRremote/IRremoteInt.h:92: error: 'uint8_t' does not name a type
sketch_dec09a.ino: In member function 'void IRsendDummy::useDummyBuf()':
sketch_dec09a:87: error: 'volatile struct irparams_t' has no member named 'rcvstate'
sketch_dec09a:88: error: 'volatile struct irparams_t' has no member named 'rawlen'
sketch_dec09a:93: error: 'volatile struct irparams_t' has no member named 'rawlen'
sketch_dec09a:98: error: 'volatile struct irparams_t' has no member named 'rawlen'
sketch_dec09a:104: error: 'volatile struct irparams_t' has no member named 'rawlen'
sketch_dec09a:109: error: 'volatile struct irparams_t' has no member named 'rawlen'
sketch_dec09a:113: error: 'volatile struct irparams_t' has no member named 'rawlen'
sketch_dec09a:114: error: 'volatile struct irparams_t' has no member named 'rawlen'

can sb pls help me what i do wrong ??

i use atm an 1.04 version

thx if sb can solve that !

Unknown said...

Hi there,

I'm busy making a system that is able to create different light patterns to build into a little house. The program I wrote works with buttons, but now I want to control it using a remote control. I bought an ir-sensor and a little remote control of DFRobot. Now I cannot manage getting the arduino read the signals. How can I make a code that tells the arduino that when I press a certain button on the remote control, a certain light pattern is selected?

Thanks in advance.

Sjef said...

Hey, I copied the folder to /Arduino/libraries and named it "IRremote".

But when I want to upload an example to my Arduino, I get all these errors.

These are the first (I can only post 4.096 characters):

/Users/Sjef/Documents/Arduino/libraries/IRremote/IRremote.cpp:13:25: error: IRremoteInt.h: No such file or directory
/Users/Sjef/Documents/Arduino/libraries/IRremote/IRremote.cpp:18: error: 'irparams_t' does not name a type
/Users/Sjef/Documents/Arduino/libraries/IRremote/IRremote.cpp: In member function 'void IRsend::sendNEC(long unsigned int, int)':
/Users/Sjef/Documents/Arduino/libraries/IRremote/IRremote.cpp:66: error: 'NEC_HDR_MARK' was not declared in this scope
/Users/Sjef/Documents/Arduino/libraries/IRremote/IRremote.cpp:67: error: 'NEC_HDR_SPACE' was not declared in this scope
/Users/Sjef/Documents/Arduino/libraries/IRremote/IRremote.cpp:69: error: 'TOPBIT' was not declared in this scope
/Users/Sjef/Documents/Arduino/libraries/IRremote/IRremote.cpp:70: error: 'NEC_BIT_MARK' was not declared in this scope
/Users/Sjef/Documents/Arduino/libraries/IRremote/IRremote.cpp:71: error: 'NEC_ONE_SPACE' was not declared in this scope
/Users/Sjef/Documents/Arduino/libraries/IRremote/IRremote.cpp:74: error: 'NEC_BIT_MARK' was not declared in this scope
/Users/Sjef/Documents/Arduino/libraries/IRremote/IRremote.cpp:75: error: 'NEC_ZERO_SPACE' was not declared in this scope
/Users/Sjef/Documents/Arduino/libraries/IRremote/IRremote.cpp:79: error: 'NEC_BIT_MARK' was not declared in this scope
/Users/Sjef/Documents/Arduino/libraries/IRremote/IRremote.cpp: In member function 'void IRsend::sendSony(long unsigned int, int)':
/Users/Sjef/Documents/Arduino/libraries/IRremote/IRremote.cpp:85: error: 'SONY_HDR_MARK' was not declared in this scope
/Users/Sjef/Documents/Arduino/libraries/IRremote/IRremote.cpp:86: error: 'SONY_HDR_SPACE' was not declared in this scope
/Users/Sjef/Documents/Arduino/libraries/IRremote/IRremote.cpp:89: error: 'TOPBIT' was not declared in this scope
/Users/Sjef/Documents/Arduino/libraries/IRremote/IRremote.cpp:90: error: 'SONY_ONE_MARK' was not declared in this scope
/Users/Sjef/Documents/Arduino/libraries/IRremote/IRremote.cpp:94: error: 'SONY_ZERO_MARK' was not declared in this scope
/Users/Sjef/Documents/Arduino/libraries/IRremote/IRremote.cpp: In member function 'void IRsend::sendRC5(long unsigned int, int)':
/Users/Sjef/Documents/Arduino/libraries/IRremote/IRremote.cpp:120: error: 'RC5_T1' was not declared in this scope
/Users/Sjef/Documents/Arduino/libraries/IRremote/IRremote.cpp:124: error: 'TOPBIT' was not declared in this scope


Does anyone know what I should do?

Sjef said...

Sorry, I didn't include all files. I, now, did copy ALL files and still get a lot of errors.

In file included from /Users/Sjef/Documents/Arduino/libraries/IRremote/IRremote.cpp:13:
/Users/Sjef/Documents/Arduino/libraries/IRremote/IRremoteInt.h:87: error: 'uint8_t' does not name a type
/Users/Sjef/Documents/Arduino/libraries/IRremote/IRremoteInt.h:88: error: 'uint8_t' does not name a type
/Users/Sjef/Documents/Arduino/libraries/IRremote/IRremoteInt.h:89: error: 'uint8_t' does not name a type
/Users/Sjef/Documents/Arduino/libraries/IRremote/IRremoteInt.h:92: error: 'uint8_t' does not name a type
/Users/Sjef/Documents/Arduino/libraries/IRremote/IRremote.cpp: In member function 'void IRsend::mark(int)':
/Users/Sjef/Documents/Arduino/libraries/IRremote/IRremote.cpp:173: error: 'delayMicroseconds' was not declared in this scope
/Users/Sjef/Documents/Arduino/libraries/IRremote/IRremote.cpp: In member function 'void IRsend::space(int)':

Etc., etc.

Sub said...

Hello,

Has anyone had luck working with LG Air Conditioning remotes?

When I record the commands they are received like:
168E4DB2
Unknown encoding: 168E4DB2 (32 bits)
Raw (60): -30050 8550 -4000 500 -1500 500 -550 450 -550 450 -550 450 -1500 500 -550 450 -550 450 -550 450 -550 450 -550 450 -550 450 -1500 500 -550 450 -550 450 -550 450 -550 450 -550 450 -550 450 -550 450 -550 450 -550 450 -550 450 -550 450 -550 450 -550 450 -550 450 -550 450 -1550 450

unsigned int acON[60] = {-30050 .... 450};

Then I try to send like irsend.sendRaw(acON, 60, 32);
or
irsend.sendNEC(0x168E4DB2, 32);

Neither one works.

If I try to receive/send commands to a TV (Samsung and LG) it works, so it shouldn't be related with the hardware.

Can anyone help me?

Regards,
Filipe

Anonymous said...

Filipe: Google it!! There are many links. Here is one.

http://forum.arduino.cc/index.php?topic=81997.0

Solved: LG air conditioning codes

Unknown said...

Hello,
On irsend.sendNEC is hung, on serial is working. Where is the mistake ?
#include
int receiver = 11;
IRrecv irrecv(receiver);
decode_results results;
IRsend irsend;

void setup()
{
//Serial.begin(9600);
irrecv.enableIRIn();
}
void translateIR() // takes action based on IR code received
{
switch(results.value)
{
//case 0x20DF40BF: Serial.println(0xAAAAAAAA, HEX); break;
//case 0x20DFC03F: Serial.println(0xBBBBBBBB, HEX); break;
//case 0x20DF906F: Serial.println(0xBBBBBBBB, HEX); break;
case 0x20DF40BF: irsend.sendNEC(0x10EF58A7, 32); break;
case 0x20DFC03F: irsend.sendNEC(0x10EF708F, 32); break;
case 0x20DF906F: irsend.sendNEC(0x10EF08F7, 32); break;
}
delay(100);
}
void loop()
{
if (irrecv.decode(&results)) // have we received an IR signal?
{
translateIR();
{
irrecv.resume(); // receive the next value
}
}
}

Anonymous said...

Bogdan:

Your IR transmitter may not work. Can you see it transmitting if you look at the IR transmitter with a camera?

Danny said...

alright so ive been reading that i have to use pin 3 because of the code written.thats fine my question is can i use this same code with my arduino uno?
when my ir led is on pin 13 im transmittiting but have found nowhere to edit the code so it will use pin 13.ive read that because of the library code i wont be able to change it so does anyone off the top off theie head know which pin i could use on the arduino uno
thanks

widgetNinja said...

Looking for insight on why the library might not work properly on a Leonardo board? Worked fine on my Duemilanove but on the Leonardo it doesn't.

Great library, works super with the JVC and SONY TV I am trying to control.

Unknown said...

I am making a tv remote controlled robot. when i launch the serial monitor to see which button sends which hex code. but the problem is the same btton is producing different hex codes. Can someone help me

druida said...

Hi Ken

I trying to control my LG projector with arduino but I run into difficulties. The remote buttons decode for NEC protocol (bur I did some research and the NEC should start with FF) so it's not it:

Decoded NEC: 20DFB54A (32 bits) POWER ON
Raw (68): 22386 8950 -4400 600 -500 600 -500 600 -1600 650 -500 600 -500 600 -500 600 -500 600 -500 600 -1600 650 -1600 600 -500 600 -1600 600 -1650 600 -1600 600 -1600 600 -1650 600 -1600 600 -500 600 -1600 600 -1650 600 -500 600 -1600 600 -500 600 -1600 650 -500 600 -1600 600 -500 600 -500 600 -1650 600 -500 600 -1600 600 -500 600

I follow what others say: To clean the raw data you get from the dump -demo, you need to erase the first number, then convert all negative numbers to positive and place commas between the numbers.

unsigned int projector_onoff[68]={8950,4400,600,500,600,500,600,1600,650,500,600,500,600,500,600,500,600,500,600,1600,650,1600,600,500,600,1600,600,1650,600,1600,600,1600,600,1650,600,1600,600,500,600,1600,600,1650,600,500,600,1600,600,500,600,1600,650,500,600,1600,600,500,600,500,600,1650,600,500,600,1600,600,500,600};
irsend.sendRaw(projector_onoff, 68, 38);

Both my receiver and transmitter and the library works fine. Any idea what to do next? I don't want to give up if I got so far. Remote's type is:
MKJ50025104

Thank you for your time!

Anonymous said...

Does there happen to be a version that uses the timers compatable with the Attiny85? -Thanks Jack

Unknown said...

Yes, there are see my fork and GIST example, as I used the ATtiny85 from a DigiSpark.

my example with ATtiny85
mpflaga's GIT hub of IRremote

Where my fork is based off of the below fork
microtherion's fork of library

Unknown said...

By any chance is there a more modular version of this library rather than a 'one shoe fits all'? I really want to use IR in my project but a 9k hit for just the basics is huge id not going to fit. It would be great if it could be selectable for 'Rx Only' and just for a specific remote type. Alternatively, are there some other IR libraries available to do this? Almost every search ends back here!

Anonymous said...

Andrew H - That is an excellent idea. I am looking at this code now. I would gladly help you to break it out but understand it is a hobby for me. If you have business reasons, I don't want to work towards a deadline.
Let me know here.

Lauszus said...

Andrew,

You should check out my blog post: http://blog.tkjelectronics.dk/2012/03/attinyremote/.

It was originally a modified version of this library, but I ended up using highly optimized code for my specific needs.

The code is available here: https://github.com/TKJElectronics/ATtinyRemote.

Regards
Lauszus

Unknown said...

How much overhead does that timer interrupt take when nothing is being received? I was wondering if it would be possible to make the RX pin an interrupt and not start the timer until the first IR state change occurs. That way the timer consumes no overhead until it is actually needed. Once a complete character is received, the timer could be stopped, or the main program could decide when to shut down the timer (such as after a sequence of commands was received, or a long enough period of quiet was observed).

Unknown said...

BTW, your code works very well on my setup. I'm using an ATMega1284P with the Maniacbug Arduino mod. My HW is clocked at 18.432mhz (EXACT multiple of common baud rates, and I had a rock on that frequency). I removed all of the transmit code, and all the receive code for everything other than the NEC protocol (since that's what I'm using and I don't need the transmit functions). I'm using timer3 on the atmega1284 (since that time uses the SPI pins, and I don't need to generate PWM).
As I wrote before my only concern is the background overhead when not receiving IR, so I might look into shutting down the timer until an opening wavefront is received, then shut it down again a few seconds after the last IR signal is found. My selected receive pin is an interrupt line.

Kwabena said...

Hi, I'm new to Arduino and programming but I have a simple question. How do you know what to put in the IRcode position. For example:
irsend.sendSony(0xa90, 12)
the IR code was 0xa90. Are theses already defined? If so, where can i find them?
Thanks

Anonymous said...

Kwabena: You either decode them from the remote that you have or Google "IR codes".
A good source is:
http://lirc.sourceforge.net/remotes/

Anonymous said...

Hi all, can anybody point me to the location of the documentation for this library, I cannot find it and would like a list of all the functions available if there is any.

Unknown said...

Hi, I am trying to control my setop box. I don't have an IR receiver but found its code and it's basically using NEC protocol. I call the sendNEC and see the LED is transmitting but nothing really happens. Any ideas?

my code: irsend.sendNEC(0x00000000000004FB, 16);


name YES
bits 16
flags SPACE_ENC|CONST_LENGTH
eps 30
aeps 100

header 9042 4558
one 555 1682
zero 555 570
ptrail 544
repeat 9041 2296
pre_data_bits 16
pre_data 0x213C
gap 108556
min_repeat 0
toggle_bit 0


begin codes
power 0x000000000000847B
1 0x0000000000000CF3
2 0x000000000000946B
3 0x0000000000009C63
4 0x00000000000014EB
5 0x00000000000004FB
6 0x0000000000001CE3
7 0x0000000000004CB3
8 0x00000000000054AB
9 0x00000000000044BB
exit 0x0000000000008C73
0 0x000000000000CC33
10 0x000000000000F40B
mute 0x000000000000A45B
return 0x0000000000005CA3
vol+ 0x000000000000649B
vol- 0x000000000000E41B
channel+ 0x000000000000AC53
channel- 0x000000000000EC13
guide 0x000000000000748B
mosaic 0x0000000000006C93
yes 0x000000000000C43B
up 0x000000000000D42B
down 0x00000000000024DB
left 0x0000000000002CD3
right 0x000000000000DC23
? 0x00000000000034CB
+ 0x0000000000003CC3
orange 0x0000000000007C83
green 0x000000000000B44B
yellow 0x000000000000BC43
blue 0x000000000000FC03
envelope 0x000000000000C23D
B 0x00000000000042BD
A 0x000000000000827D
i 0x00000000000002FD
end codes

end remote

weldsmith said...

ken I have been working on the multiple receive library that you modified back in May of 2010. I have had some success turning leds on with it but can not receive a Hex value from the pins. do you have any advice. I do know that the library was unfinished, but I am so close. Thanks for all your work!

Mario said...

hi,
i have one of them IR keypads,
http://arduino-info.wikispaces.com/IR-RemoteControl
how can i use that remote control as an IR Keypad? i mean there is any way to map them codes to have just numbers as output? Like the 4x4 matricial keypad?
thank you

jjjjjj said...

Hi Ken,

It's amazing that you're still answering so many questions to this blog even after 3 years.

Thanks for this code and how great it works.

Question
One thing I'm trying to do is push RAWBUF past 255. Even at 256 it crashes the Uno R3 (zero response).

The AC unit remote just keeps spitting out data

I feel like I should still have memory available to push it to 300, but for some reason I don't. Any ideas?

Thanks for this library it's awesome!

Justin

Anonymous said...

Awesome library!

I used a new apple remote with the library and was able to find when a button was pressed. I thought it might be cool to control some kind of robot with this!
Here is the code:
/*
* IRremote: IRrecvDemo - demonstrates receiving IR codes with IRrecv
* An IR detector/demodulator must be connected to the input RECV_PIN.
* Version 0.1 July, 2009
* Copyright 2009 Ken Shirriff
* http://arcfn.com
*/

#include

int RECV_PIN = 2;

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);
irrecv.resume(); // Receive the next value
}
if (results.value == 4001586391) { //change the number here if your remote isn't working to the number that show up in the serial moniter if you tap the button.
Serial.println("up"); //change this line to make it do whatever you want when that button is pressed
}
if (results.value == 2011254963) {
Serial.println("up fast");
}
if (results.value == 2836161645) {
Serial.println("down"); //change this line to make it do whatever you want when that button is pressed
}
if (results.value == 2011246771) {
Serial.println("down fast");
}
if (results.value == 2323227209) {
Serial.println("right"); //change this line to make it do whatever you want when that button is pressed
}
if (results.value == 222827497) {
Serial.println("left"); //change this line to make it do whatever you want when that button is pressed
}
if (results.value == 2011271347) {
Serial.println("left fast");
}
if (results.value == 2011259059) {
Serial.println("right fast");
}
if (results.value == 3890407325) {
Serial.println("play/pause"); //change this line to make it do whatever you want when that button is pressed
}
if (results.value == 2011298483) {
Serial.println("play/pause fast");
}
if (results.value == 291812799) {
Serial.println("center button"); //change this line to make it do whatever you want when that button is pressed
}
if (results.value == 2011249331) {
Serial.println("center button fast");
}
}

Alasdair said...

Is there any reason why transmission wouldn't work with an ATTINY84 running at 12MHz?

Im using this code in a V-USB setup and 12MHz is required for usb interfacing.

The hardware setup is fine as I can test successfully with a TINY84 running at 8MHz.

Unknown said...

yes, there are some resource conflicts of the timers for generating the PWM. It possible. But would take some work.

Alasdair said...

Could you be more specific?

The V-USB implementation is using TIMER0 only as far as I'm aware.

Where is the conflict?

Alasdair said...

Also worth mentioning is that receiving @ 12MHz is working fine.

scruffy said...

Hi folks,
I am Trying to send a code to my Panasonic DVD player.
I have got the code as numbers (0082 0015 0089 0004 00F2 0033 0017 0010 0091 0013)
unfortunately i am compleatly new to Programming (still on tutorials starting with Arduino Uno).
can someone help me if its not to mutch work.

Thanks,
Scruffy

Unknown said...

I planned on using your code to read the IR output from my Mitsubishi air conditioner remote. The remote sends fan speed, temp, mode (heat, cool, dehumidify, etc.), vane positions, and time to the AC unit every time a button is pushed, so the command string has to be quite long. I read somewhere it is 128 bits. My thought was to cycle between a couple of commands (i.e. cool 76 and cool 75) to see where in the code the temperature would be. Then I could build the command based on my needs. How can I expand what you read to catch all the data from my remote?

Anonymous said...

Hi all. I am trying to code my arduino to receive a code from a sony device, increment it by one and send the code back to the device. I am not too familiar with coding so I am looking for any help you can give me. Thanks!

Anonymous said...

i want to control my samsung AC with Arduino then how can i know what protocal used in this and how can i control
suggest me

Ema said...

I used IRrecvDemo , to decode the codes from my remote. For button "ok" I recieved the code "0XFFE01F".
All worked perfectly. I saved all codes into IRcodes.h file, then I used this file to check weither the codes are correct or not.
They looked fine, and it recognised all buttons from my remote.
But the problem appears when I press the powerOn button from my robot. Then all codes are different.And my program don't work, because the remote control transmits different codes, or is something wrong with the files?
This is my code:
#include
#include

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

void setup()
{
Serial.begin(9600);
irrecv.enableIRIn(); // Start the receiver
Serial.println("Ready to decode: ");
}

void loop() {
if (irrecv.decode(&results)) {
test(results.value);
irrecv.resume();
}
}

void test(unsigned long var)
{
switch(var)
{
case ok:
Serial.println("OK");
break;
case inainte:
Serial.println("Inainte");
break;
case inapoi:
Serial.println("Inapoi");
break;
case stanga:
Serial.println("Stanga");
break;
case dreapta:
Serial.println("Dreapta");
break;
case zero:
Serial.println("0");
break;
case unu:
Serial.println("1");
break;
case doi:
Serial.println("2");
break;
case trei:
Serial.println("3");
break;
case patru:
Serial.println("4");
break;
case cinci:
Serial.println("5");
break;
case sase:
Serial.println("6");
break;
case sapte:
Serial.println("7");
break;
case opt:
Serial.println("8");
break;
case noua:
Serial.println("9");
break;
case a:
Serial.println("A");
break;
case account:
Serial.println("Account");
break;
case albastru:
Serial.println("Albastru");
break;
case back:
Serial.println("Back");
break;
case canalm:
Serial.println("Canal minus");
break;
case canalp:
Serial.println("Canal plus");
break;
case cinema:
Serial.println("Cinema");
break;
case details:
Serial.println("Details");
break;
case favorites:
Serial.println("Favorites");
break;
case goto:
Serial.println("Goto");
break;
//...
case radio:
Serial.println("Radio");
break;
case rosu:
Serial.println("Rosu");
break;
//...
case repetare:
break;
default:
Serial.print("Don't recognise the button");
Serial.println(results.value);
break;
}
}

As I said, if i run this program, all works perfectly, it recognises all buttons, but when I pres PowerOn button from my robot, then i recieve most of time "Don't recognise the button".
And when I check what codes are recieved,i see different codes.
Instead of this code: 0XFFE01F , for "ok" button,
I recieve this ones:
Don't recognise the button: 4034314555
Don't recognise the button: 4034314555
Don't recognise the button: 4034314555
Don't recognise the button: 255
Don't recognise the button: 255
Don't recognise the button: 4034314555

For "red" button I recieve:
Don't recognise the button: 2318624347
Don't recognise the button: 490562393
Don't recognise the button: 1235919367
Don't recognise the button: 3964794313
Don't recognise the button: 2318624347
Don't recognise the button: 3809758591
Don't recognise the button: 4014358672
Don't recognise the button: 1236334118
Don't recognise the button: 4239130558
Don't recognise the button: 1962577162
Don't recognise the button: 2318624347

Can anyone help with this issue?

Alasdair said...

@ema. What do you mean by 'press the powerON button from my robot'?

Does the robot physically press a button on the remote control you have learned?

Ema said...

I am not sure how to explain it.
I made a picture with that button.
http://s28.postimg.org/7xtv7r565/asdasfasdadf.jpg
On the robot is a button, and when I press it, then it starts to execute the program. When I press it again, it stopps.
If i connect the robot to PC, and i do not press the button, then the program shows me all the buttons that i press from remote control. When I press that button (I guess power on) then my program shows me different codes.
I can save those code too, but sometimes I recieve more than 10 different codes per button.

This is not the only issue.
If I upload my program, then the robot doesnt go forward; it goes back, left and right.
I checked the code, but I can't find the problem, and when I don't use this program, my robot goes forward. I can't figure out why it doesnt't go forward with the IR program.
this is the code for back/on/left/right

int MOTOR2_PIN1=3;
int MOTOR2_PIN2=5;
int MOTOR1_PIN1=6;
int MOTOR1_PIN2=9;

void setup()
{

pinMode (MOTOR1_PIN1, OUTPUT);
pinMode (MOTOR1_PIN2, OUTPUT);
pinMode (MOTOR2_PIN1, OUTPUT);
pinMode (MOTOR2_PIN2, OUTPUT);
Serial.begin(9600);
irrecv.enableIRIn(); // Start the receiver
Serial.println("Ready to move: ");
}


//....
void back(int viteza) // înapoi
{
analogWrite (MOTOR1_PIN1, 0);
analogWrite (MOTOR1_PIN2, viteza);
analogWrite (MOTOR2_PIN1, 0);
analogWrite (MOTOR2_PIN2, viteza);
}

void forward(int viteza) // înainte
{
analogWrite (MOTOR1_PIN1, viteza);
analogWrite (MOTOR1_PIN2, 0);
analogWrite (MOTOR2_PIN1, viteza);
analogWrite (MOTOR2_PIN2, 0);
}

void ok() //stop
{
digitalWrite (MOTOR1_PIN1, LOW);
digitalWrite (MOTOR1_PIN2, LOW);
digitalWrite (MOTOR2_PIN1, LOW);
digitalWrite (MOTOR2_PIN2, LOW);
}


I'm using same code with this loop:
void loop()
{
forward(150);
delay(2000);
back(150);
delay(2000);
ok();
delay(2000);
}

And it goes normaly forward, but with the IR program,when I press forward button it goes to right .Or if i copy the loop code to my IR program, it still goes to right,instead of going forward.

Alasdair said...

@ema you should ask on the Arduino forums, none of this is a problem with the IRRemote library.

Best of luck.

Ema said...

Thanks for advice. I'm new in this stuff.

Ema said...

I searched through the IRremote library and I founded this:
void IRsend::mark(int time) {
// Sends an IR mark for the specified number of microseconds.
// The mark output is modulated at the PWM frequency.
TIMER_ENABLE_PWM; // Enable pin 3 PWM output
delayMicroseconds(time);
}
/* Leave pin off for time (given in microseconds) */
void IRsend::space(int time) {
// Sends an IR space for the specified number of microseconds.
// A space is no output, so the PWM output is disabled.
TIMER_DISABLE_PWM; // Disable pin 3 PWM output
delayMicroseconds(time);
}

I took this code from IRremote.cpp
It looks like that some codes are disableing my pin 3PWM, and this is the Pin which I use for "go forward" . I guess that is why my robot doesn't go forward , because the Pin is disabled. Even I unncoment #define IR_USE_TIMER1 , I still can't use all my motors, unless i change the analogWrite with digitalWrite. But I need in my project the analogWrite.
How to change the file, to work properly?
Is there anything that I can change in the IRremote?

Unknown said...

Ken,

This is a great post it helped me develop an IR control for a handicapp person. However i need to step up to an a atmega 1284p so that I have access to more ports and memory. However the librbaru does not seem to work. It appears the code hangs when I start the receiver.

irrecv.enableIRIn();

Is there a change that needs to happen to make this possible or is the 1284p chip not supported?

Thanks

Anonymous said...

Michael:
Here you go:
http://people.ece.cornell.edu/land/courses/ece4760/IR_comm/

Anonymous said...

Hi all. I am trying to code my arduino to receive a code from a sony device, increment it by one and send the code back to the device. I am not too familiar with coding so I am looking for any help you can give me. Thanks!

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

i am getting errors while i am using
code in this blog

:822: error: 'PANASONIC_HDR_SPACE' was not declared in this scope
C:\Users\Asset N4\Desktop\arduino-1.0.5-r2\libraries\IRremote\IRremote.cpp:822: error: 'MATCH_MARK' was not declared in this scope
C:\Users\Asset N4\Desktop\arduino-1.0.5-r2\libraries\IRremot

how can i rectify them

Unknown said...

I fixed it! I find the 1284p a little finicky, it might just be me but none the less everything is working.

The issue with receiving IR signals worked itself out. Not exactly sure. It might have something to do with running make clean the make upload.

Sending codes was a bigger issue. Though a few dasy of research and post here that was made this weekend I found a file pins_arduino.h that was in a bobuino folder. I copied that to the standard folder and everything started working. I think if I just told the compiler that it was a bobuino it would have just worked. However I work from a cli on a mac and I am still learning the ins and outs.

If anybody has questions or suggestions let me know.

Alasdair said...

@ema It depends on what Arudino you are using. The smaller arduinos only have one or two pins which IRRemote could work with.

Your best bet is to find an Arduino which allows you to attach your servos to different pins and use AnalogWrite on them.

I wouldn't modify the IRRemote code at all.

Anonymous said...

hi ken
when i used this code for my samsung remote
i am getting error like
recieved unexpecetd code and storing as raw
i want know
is my code is stored in the arduino??? n how can i resend that code????
and one more thing how can i know protocl that is used in my samsung remote???

ben said...

hello
Your site is quite good ! thanks

I have a mitsibushi air cooler with a IR Remote control.
I would like to manage the on/off of the air cooler device remotly with aduino.
I can dump read the IR on code from the remote (see below)

E1CC9186
Unknown encoding: E1CC9186 (32 bits)
Raw (100): 12064 3400 -1700 450 -1250 500 -1200 450 -400 450 -450 400 -450 500 -1200 500 -350 450 -400 500 -1200 450 -1300 500 -350 500 -1200 500 -350 450 -400 450 -1250 550 -1200 450 -400 450 -1250 450 -1250 450 -450 400 -450 400 -1300 450 -400 450 -400 450 -1250 450 -400 550 -350 400 -450 500 -350 500 -350 500 -350 500 -350 500 -400 500 -350 500 -350 500 -350 500 -400 450 -400 450 -400 500 -350 500 -350 500 -350 500 -350 500 -400 450 -400 500 -350 500 -350 500 -350 500

The first issue is that the protocol seems not to be ‘known’ –> Unknown encoding,

-Is there a library IRLib to manage mitsubishi air cooler ?
-How do i have to manage my code in order to reproduce it ?
-like this ?

unsigned int rawCode[68] = {12064, 3400, 1700, 450, 1250, 500, 1200, 450, 400, 450, 450 400, 450, 500, 1200, 500, 350, 450, 400, 500, 1200, 450, 1300, 500, 350, 500, 1200, 500, 350, 450, 400, 450, 1250, 550, 1200, 450, 400, 450, 1250, 450, 1250, 450, 450, 400, 450, 400, 1300, 450, 400, 450 ,400, 450, 1250, 450, 400, 550, 350, 400, 450, 500, 350, 500, 350 500, 350, 500, 350, 500, 400, 500, 350, 500, 350, 500, 350, 500, 400, 450, 400, 450, 400, 500, 350, 500, 350, 500, 350, 500, 350, 500, 400, 450, 400, 500, 350, 500, 350, 500, 350 500};

irsend.sendRaw(rawCode,100,38);

-How can i be sure that my IRLed is working?
-How can i know the frequency 38KHz?

A lot of question …
Thanks in advance

Tim Gray said...

I am confused as to how you put in codes. NEC codes for example are Device and Command.

I have a document that shows that my codes for NEC are for Device 00 and command 31

How do I convert that into 8 hex numbers? do I pad them? so that i send 0000001F? is your code for NEC expecting a full 64 bits? or is it a psudeo NEC code that I can only get by running the recieve and seeing what comes out of the sketch?

Unknown said...

Hi everyone! I am new to arduino programming.I have a trouble when one way data sending between two arduinos. So that; i first found this library and wish communicate by using a 2 pin ir LED and a 3 pin IR phototransistor and implemented the necessary hardware setup. But i can not send data using this library. The data consist of 4 decimal numbers obtained from a calculation in another sketch. Is there a simple way to transmit the data using this library from an arduino to another arduino? Can anyone suggest a program code for this aim?

All the best!

aldagoni7 said...

Hi guys, I 'm trying to use this library to create an IR remote for air conditioners, until now I can control most of Air conditioners , but I'm having problem with one of the brand CARRIER, the data stored by the code is as follows:

Received unknown code, saving as raw
 m4500 m200 s1100 s400 s550 m300 m150 m650 s1500 S1550 S1450 m600 m700 m700 s400 s450 s1600 m650 s1500 m650 m650 m650 s450 s450 s450 m650 m650 m650 s1100 m50 s350 s450 s450 m650 m650 m600 s1500 S1150 s350 m50 m700 m600 s400 s400 S1550 m700 m700 m650 s1500 S1450 S1450 s1500 m700 m650 m700 m650 s450 s1500 S1450 m550 s1600 m650 m700 m650 s450 s450 s450 m650 m650 m550 s1600 m650 s450 s450 s450 m650 m650 m750 s1500 m650 s1500 S1400 s450 m650 m650 m650 s450 s450 s450 m650 m650 m650 s450 s450 s550 m550 m650 m650 s450 S1400 m650 m650 s1500 s1500 s1200 M1050 m650 m650 s1500 S4600 S4300 m4550 m650 m650 s1500 m650 s1500 s1500 s450 m650 m650 m550 s450 s550 s450 m650 m650 m650 s1500 m650 s1500 m650 s450 s450 s450 m650 m550 m650 s1500 m650 s1600 m650 s1500 s450 s450 m650 m700 m650 s1500 S1450 m700 m650 s1500 S1450 s400 m700 m650 m700 s1500 S1450 S1450 m700 m700 m700 s400 s400 s450 m650 m700 m700 S1450 m650 s400 s450 s400 m700 m700 m650 s1500 m650 s1500 m650 s1500 s400 s450 m700 m650 m650 s450 s450 s500 m550 m700 m650 s450 s450 s400 m650 m700 s1500 m650 s1500 m650 s1500 m650 s1500 m550 s1600 m650

however the CARRIER one does not respond, any ideas about what could be the problem??

thanks a lot!

Unknown said...

Thanks for the source code...
but I'm still having problem with using your codes in my library.
I already save your codes in my libraries.
but when I try to compile your codes, the compiler said "sketch_mar28a:4: error: 'IRrecv' does not name a type
sketch_mar28a:5: error: 'decode_results' does not name a type
sketch_mar28a.ino: In function 'void setup()':
sketch_mar28a:10: error: 'irrecv' was not declared in this scope
sketch_mar28a.ino: In function 'void loop()':
sketch_mar28a:14: error: 'irrecv' was not declared in this scope
sketch_mar28a:14: error: 'results' was not declared in this scope"

could you help me for this problem ken??
Regards

Unknown said...

Anybody have any success with a Direct TV RC64 or RC65 remote? I know I get one message per button press. Here is a receive dump.
Unknown encoding: C9767F76 (32 bits)
Raw (20): -29700 3000 -1150 1200 -1150 650 -550 600 -550 650 -550 650 -550 600 -1150 650 -550 650 -1150 600
34498102
Unknown encoding: 34498102 (32 bits)
Raw (20): 29830 5950 -1200 1200 -1150 650 -550 650 -550 1200 -550 650 -1150 1200 -550 1250 -1150 1200 -1150 650
34498102
Unknown encoding: 34498102 (32 bits)
Raw (20): -29650 3050 -1100 1250 -1150 650 -500 650 -550 1250 -550 600 -1150 1250 -550 1250 -1100 1250 -1150 600
34498102
The first two pairs aren't consistent between repeat button presses but the next 8 pairs are each time.
I'm trying to make an IR repeater so I can change the DVR in another room. Maybe I shouldn't worry about the codes and just Xbee the RAW numbers from the receiving Arduino to the sending Arduino. Any thoughts?
Thanks!

Matz said...

Hi Ken and thanks for this awsome library!
I have a sketch that work with timer 1 and pin 9, but I need multiple receiver, so i want to move to the dev version with the IRparam array. What do I need to change to use timer 1 and pin 9 like the regular lib ?

It is this way because otherwise it conflicts with the tone() function.

Thank for any help!

Unknown said...

Hi Ken (or anyone who may be able to help),

I am a newbie to both Arduino and IR remote codes.

I purchased the Android "Smart IR Remote" application (https://play.google.com/store/apps/details?id=com.remotefairy) to create a Universal Controller for all my devices at home. However, there are some remotes that need to be "learnt" as the remotes do not exist in the "Smart IR Remote" database.

Smart IR Remote allows you to "learn" codes only by programming/entering the pronto hex codes for each command

I have your IR Remote libray on my Arduino and I am successfully reading my remote controls and outputting the results to the serial monitor as per your code.

Question 1:
Is it possible to change the serial output to Pronto Hex Format? If so, can you help me with the code for this or point me to an existing library?

Question 2:
On some remotes, pressing the same button, does not always result in the same set of raw data. Why would this be? I get the impression that it may be a "scrambled" signal. Or is this just inaccuracies in the sensitivity or resolution of the IR sensor?

Regards
Mike

Mahmoud said...

it didn't work with Arduino version 1.5.6 what can i do ?

Matt said...

How would I change the library to read an inverted signal, no signal would now be 0v and signal will now be 5v.

Admin said...

How to decode LG AC remote.....which is sending all information like Temp , FAN speed, Mode and Swing.

Anonymous said...

Tulan: Google it. There are many links to help you.

Alexander said...

I get this error on IDE v 1.0.4.
"
/Users/Alexander/Library/Arduino Sketches/Attiny-Arduino1.0.4/libraries/IRremote/IRremote.cpp: In member function 'void IRsend::mark(int)':
/Users/Alexander/Library/Arduino Sketches/Attiny-Arduino1.0.4/libraries/IRremote/IRremote.cpp:227: error: 'TCCR2A' was not declared in this scope
/Users/Alexander/Library/Arduino Sketches/Attiny-Arduino1.0.4/libraries/IRremote/IRremote.cpp:227: error: 'COM2B1' was not declared in this scope
/Users/Alexander/Library/Arduino Sketches/Attiny-Arduino1.0.4/libraries/IRremote/IRremote.cpp: In member function 'void IRsend::space(int)':
/Users/Alexander/Library/Arduino Sketches/Attiny-Arduino1.0.4/libraries/IRremote/IRremote.cpp:235: error: 'TCCR2A' was not declared in this scope
/Users/Alexander/Library/Arduino Sketches/Attiny-Arduino1.0.4/libraries/IRremote/IRremote.cpp:235: error: 'COM2B1' was not declared in this scope
/Users/Alexander/Library/Arduino Sketches/Attiny-Arduino1.0.4/libraries/IRremote/IRremote.cpp: In member function 'void IRsend::enableIROut(int)':
/Users/Alexander/Library/Arduino Sketches/Attiny-Arduino1.0.4/libraries/IRremote/IRremote.cpp:253: error: 'TIMSK2' was not declared in this scope
/Users/Alexander/Library/Arduino Sketches/Attiny-Arduino1.0.4/libraries/IRremote/IRremote.cpp:263: error: 'TCCR2A' was not declared in this scope
/Users/Alexander/Library/Arduino Sketches/Attiny-Arduino1.0.4/libraries/IRremote/IRremote.cpp:263: error: 'WGM20' was not declared in this scope
/Users/Alexander/Library/Arduino Sketches/Attiny-Arduino1.0.4/libraries/IRremote/IRremote.cpp:263: error: 'TCCR2B' was not declared in this scope
/Users/Alexander/Library/Arduino Sketches/Attiny-Arduino1.0.4/libraries/IRremote/IRremote.cpp:263: error: 'WGM22' was not declared in this scope
/Users/Alexander/Library/Arduino Sketches/Attiny-Arduino1.0.4/libraries/IRremote/IRremote.cpp:263: error: 'CS20' was not declared in this scope
/Users/Alexander/Library/Arduino Sketches/Attiny-Arduino1.0.4/libraries/IRremote/IRremote.cpp:263: error: 'OCR2A' was not declared in this scope
/Users/Alexander/Library/Arduino Sketches/Attiny-Arduino1.0.4/libraries/IRremote/IRremote.cpp:263: error: 'OCR2B' was not declared in this scope
/Users/Alexander/Library/Arduino Sketches/Attiny-Arduino1.0.4/libraries/IRremote/IRremote.cpp: In member function 'void IRrecv::enableIRIn()':
/Users/Alexander/Library/Arduino Sketches/Attiny-Arduino1.0.4/libraries/IRremote/IRremote.cpp:279: error: 'TCCR2A' was not declared in this scope
/Users/Alexander/Library/Arduino Sketches/Attiny-Arduino1.0.4/libraries/IRremote/IRremote.cpp:279: error: 'WGM21' was not declared in this scope
/Users/Alexander/Library/Arduino Sketches/Attiny-Arduino1.0.4/libraries/IRremote/IRremote.cpp:279: error: 'TCCR2B' was not declared in this scope
/Users/Alexander/Library/Arduino Sketches/Attiny-Arduino1.0.4/libraries/IRremote/IRremote.cpp:279: error: 'CS20' was not declared in this scope
/Users/Alexander/Library/Arduino Sketches/Attiny-Arduino1.0.4/libraries/IRremote/IRremote.cpp:279: error: 'OCR2A' was not declared in this scope
/Users/Alexander/Library/Arduino Sketches/Attiny-Arduino1.0.4/libraries/IRremote/IRremote.cpp:279: error: 'TCNT2' was not declared in this scope
/Users/Alexander/Library/Arduino Sketches/Attiny-Arduino1.0.4/libraries/IRremote/IRremote.cpp:282: error: 'TIMSK2' was not declared in this scope
/Users/Alexander/Library/Arduino Sketches/Attiny-Arduino1.0.4/libraries/IRremote/IRremote.cpp:282: error: 'OCIE2A' was not declared in this scope"

Unknown said...

Hi Ken.
Sorry for asking this question but I am new to this kind of decoding stuff with an Arduino Uno.
I have made the hardware like you showed. (only use a VS1838B IR receiver)
But I am receiving only weird info when I try a to decode the RC5 and RC6 code.
I mean its every time something else.
The only remote that gives the same code over and over again is a Samsung TV remote (F4BA2988 = power button)
The RC6 from the DVD = 321FFDD1 or BBE98CC8 or E3200DB6 but even this is not the same every time.
The RC5 from the TV is like this:
306E4CA9
4
80C
and more weird numbers.
I have try to read 725 comments on this blog and looked for other tutorials on the net but don't seem to get it to work with the RC5 and RC6 IR-controllers.

I hope you have an idea.
(Forgive my bad English because its not my native language.)
Thanks in advance.
Ray

Unknown said...

hello, could you please tell me how to calculate #define NEC_RPT_SPACE 2250 / RC5_RPT_length 46000. because I am trying to add the new protocol. can you give me some idea? thank you.

Unknown said...

Hi,
I would need your help in trying to emulate my microlab remote control broken(chewed) by my son.
I have found the codes for each button but they are in a format that i need some help with.
It looks like this:
< code name = "MUTE" Codeno = "0x00000000000040BF" >

< DECODING Protocol = "NEC" device = "1" subdevice = "-1" obc = "2" hex0 = "191" hex1 = "-1" hex2 = "-1" hex3 = "-1" misc = "no repeat " error = "" />
< ccf > 006d 0000 0022 0000 0156 00ab 0015 0040 0015 0015 0015 0015 0015 0015 0015 0015 0015 0015 0015 0015 0015 0015 0015 0015 0015 0040 0015 0040 0015 0040 0015 0040 0015 0040 0015 0040 0015 0040 0015 0015 0015 0040 0015 0015 0015 0015 0015 0015 0015 0015 0015 0015 0015 0015 0015 0040 0015 0015 0015 0040 0015 0040 0015 0040 0015 0040 0015 0040 0015 0040 0015 05EE


I got it from here

I appreciate you help very much.

Thank you

Unknown said...
This comment has been removed by the author.
senghun said...

hi ken
#include

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
}
}
when i compile it (









c:/program files/arduino/hardware/tools/avr/bin/../lib/gcc/avr/4.3.2/../../../../avr/bin/ld.exe: sketch_jun12b.cpp.elf section .text will not fit in region text
c:/program files/arduino/hardware/tools/avr/bin/../lib/gcc/avr/4.3.2/../../../../avr/bin/ld.exe: region text overflowed by 50 bytes
) please help me

Unknown said...

Hi
I have a problem, and hopefully they can help me, I have made the respective changes said wolfgang and change the tolerance to 35, in the library for panasonic protocol, since I have a tv see and I want to change the remote control for arduino mega. My problem is that before me appeared a stranger changes and through the numbers that appeared reaches the conclusion that the received code was 0100BCBD code after the changes by pressing the same button the message was the following "address 0 BCBD code "when you submit this code via the Panasonic protocol (address, code) nothing happens help please ps sorry for my bad English I'm Colombian

Unknown said...

Respected sir,

This library doesn't work with high frequency external interrupt code.


I was trying to implement ir_remote controlled ac dimmer with zero detection as an external interrupt . but after connecting interrupt pin this circuit or library does not work. it decodes faulty code. please suggest something

RCortarelli said...

Hello,

I´m trying to create a remote control extention and use the both code together (IRreceive and IRsender).

Below is the code:

#include

int RECV_PIN = 11;
int RECP_VCC = 9;
int RECP_GND = 10;

IRrecv irrecv(RECV_PIN);
IRsend irsend;

decode_results results;

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

//Included to use the Receptor directly on Arduino
pinMode(RECP_VCC, OUTPUT);
pinMode(RECP_GND, OUTPUT);
digitalWrite(RECP_VCC, HIGH);
digitalWrite(RECP_GND, LOW);
}

void loop() {
if (irrecv.decode(&results)) {
Serial.println(results.value, HEX);
irsend.sendNEC(results.value, 32);
delay(100);
irrecv.resume(); // Receive the next value

}
}

If I collect the value from the receiver and print it at serial works good. But if I try to send the code goes just once.

It´s impossible go away from de Sender code.

Can anybody help me?

Thanks.

! said...

How can I change the output pin that in this example is assigned to pin 3. IS it in the sketch I create or do I have to edit some file?

! said...

@RCortarelli

While I'm not an expert on the IRremote library for arduino I can forsee a problem with using both codes together (IRreceive and IRsender). Depending on how you point the sender and receiver e.g. if their in the same lin-of-sight you could potentially create an infinite loop.

! said...

How can I modify the IRrecvDemo such that the line that starts with
Serial.println(results.value, HEX);
instead of printing to the serial port as is the case with the demo it sends the code value or secuence to a LAMP server running php as if it were submitting a form.

I do not want the serial communication to be active except during upload, initial recording of the IR values, testing and debugging of the sketch.

My project will be initated by a client-side html page (accessed through a browser) that then activates the transmission of the IR values from a server-side script through the Ethernet shield via UDP as is the case with the App known as Ardumote.

In other words I open a browser and go to mymachineshostname.lan/remote/ where I am presented with a series of soft buttons that represent the original remote controls layout and functionality. when I press a button the LAMP server will translate the soft button's press into the corresponding pulse secuence, which is then sent to the arduino via UDP using the same method as Ardumote, which then is transmitted to the IR LED using the IRremote library.

However because the ethernet shield uses pin 3 to "control the reset of the W5100" based on http://www.seeedstudio.com/wiki/Ethernet_Shield_V1.0 I have to also modify the pin output from pin 3 to another PWM capable pin.

Anonymous said...

Hii sir!!
I have downloaded the IR library and put it into the libraries folder . then I opened aurdino and tried to compile the IRrecdemo but I am getting lots of errors ,I am using aurdino 1.5.7 IDE. Plz help me out!

Unknown said...

Hello everybody, I have a problem, I installed the IR library but when I try to run it I get the following message: 'IRrecv does not name a type" can anybody please tell me what I am doing wrong?
Thanks in advace

Anonymous said...

Maybe I'm too dumb ?

Why I get so many errors, seems IR Libarry is not workin' ? I'm using arduimo ide 1.05

===============================
In file included from IRrecord.pde:18:
C:\Documents and Settings\Administrator\My Documents\Arduino\libraries\IRremote/IRremote.h:13: error: stray '\302' in program
C:\Documents and Settings\Administrator\My Documents\Arduino\libraries\IRremote/IRremote.h:13: error: stray '\267' in program
C:\Documents and Settings\Administrator\My Documents\Arduino\libraries\IRremote/IRremote.h:13: error: stray '\302' in program
C:\Documents and Settings\Administrator\My Documents\Arduino\libraries\IRremote/IRremote.h:13: error: stray '\267' in program
In file included from IRrecord.pde:18:
C:\Documents and Settings\Administrator\My Documents\Arduino\libraries\IRremote/IRremote.h:318:46: error: invalid suffix "f1f4230eb4cc863ec9761f4840193eb" on integer constant
C:\Documents and Settings\Administrator\My Documents\Arduino\libraries\IRremote/IRremote.h:625: error: stray '#' in program
C:\Documents and Settings\Administrator\My Documents\Arduino\libraries\IRremote/IRremote.h:625: error: stray '#' in program
C:\Documents and Settings\Administrator\My Documents\Arduino\libraries\IRremote/IRremote.h:6: error: expected unqualified-id before '<' token
C:\Documents and Settings\Administrator\My Documents\Arduino\libraries\IRremote/IRremote.h:668: error: expected unqualified-id before numeric constant
In file included from C:\Program Files\Arduino\hardware\arduino\cores\arduino/Arduino.h:4,
from IRrecord.pde:20:
c:/program files/arduino/hardware/tools/avr/lib/gcc/../../avr/include/stdlib.h:143: error: 'size_t' has not been declared
c:/program files/arduino/hardware/tools/avr/lib/gcc/../../avr/include/stdlib.h:144: error: 'size_t' has not been declared
c:/program files/arduino/hardware/tools/avr/lib/gcc/../../avr/include/stdlib.h:175: error: 'size_t' has not been declared
c:/program files/arduino/hardware/tools/avr/lib/gcc/../../avr/include/stdlib.h:175: error: 'size_t' has not been declared
c:/program files/arduino/hardware/tools/avr/lib/gcc/../../avr/include/stdlib.h:290: error: 'size_t' was not declared in this scope
c:/program files/arduino/hardware/tools/avr/lib/gcc/../../avr/include/stdlib.h:302: error: 'size_t' does not name a type
c:/program files/arduino/hardware/tools/avr/lib/gcc/../../avr/include/stdlib.h:319: error: 'size_t' was not declared in this scope
c:/program files/arduino/hardware/tools/avr/lib/gcc/../../avr/include/stdlib.h:319: error: 'size_t' was not declared in this scope
c:/program files/arduino/hardware/tools/avr/lib/gcc/../../avr/include/stdlib.h:319: error: initializer expression list treated as compound expression
c:/program files/arduino/hardware/tools/avr/lib/gcc/../../avr/include/stdlib.h:338: error: 'size_t' has not been declared
In file included from C:\Program Files\Arduino\hardware\arduino\cores\arduino/Arduino.h:5,
from IRrecord.pde:20:
c:/program files/arduino/hardware/tools/avr/lib/gcc/../../avr/include/string.h:113: error: 'size_t' has not been declared
c:/program files/arduino/hardware/tools/avr/lib/gcc/../../avr/include/string.h:114: error: 'size_t' has not been declared
c:/program files/arduino/hardware/tools/avr/lib/gcc/../../avr/include/string.h:115: error: 'size_t' has not been declared
c:/program files/arduino/hardware/tools/avr/lib/gcc/../../avr/include/string.h:116: error: 'size_t' has not been declared
c:/program

and so on ...

Anonymous said...

Anonymous: The IR library has been in place and tested for years. You have an error or are doing something wrong or the library is in the wrong place or your code is bad.

Anthony! said...

Heya guys,
I’m having a bit of a problem with sending a raw code through the IRremote library. I’ve tried almost everything I can think of and yet I’m still not seeing results. What I’m trying to do is emulate the power button my GE air conditioner’s remote. I loaded up IRrecvDump and captured the following output:

B5E9B811 Unknown encoding: B5E9B811 (32 bits) Raw (38): -29676 8350 -4150 500 -1600 500 -1600 500 -1600 500 -550 550 -1550 500 -550 550 -1550 550 -1550 550 -4100 550 -1550 550 -1550 550 -550 500 -1600 500 -550 500 -550 550 -500 550 -500 600

I then created a sketch very similar to IRsendDemo with the following lines added:

unsigned int powerOn[38] = {-29676, 8350, -4150, 500, -1600, 500, -1600, 500, -1600, 500, -550, 550, -1550, 500, -550, 550, -1550, 550, -1550, 550, -4100, 550, -1550, 550, -1550, 550, -550, 500, -1600, 500, -550, 500, -550, 550, -500, 550, -500, 600}

void loop() {
if (Serial.read() != -1) {
Serial.println("SENDING");
irsend.sendRaw(powerOn, 38, 38); // 38 length of powerOn, and 38hz freq.
}
}

I’ve attached a pastebin link with various other captured power signals from my remote using IRremote library. It acts like it’s sending the signal, but I’m not getting a reaction from the AC unit. To verify that something was happening I replaced the IR led with a standard led and I was able to see it light up. Any help would be greatly appreciated.

It's a GE air conditioner, and an Arduino Uno. Let me know if I forgot any details.

http://pastebin.com/pkGPXKKU

Anonymous said...

Hi, I know its an old post but i really like the library. I am trying to use RC6 protocol between two arduinos.

The transmitter being Arduino nano and receiver being Arduino Mega.

I only want to send and receive RC6. Can you please guide me how to achieve this.

In the receiver side i have this in the main loop:

if (irrecv.decodeRC6(&IRresults)) {
Serial.println(IRresults.value, HEX);
irrecv.resume(); // Receive the next value
}

Now i dont understand how to process the address and command received?

Anonymous said...

Hi There

Thanks for an awesome library !

Does anyone have some code like a keypad that allows you to enter 123 and transmit with a # so for example I type in 123# and the number 123 is on the serial monitor ?

Please help

Anonymous said...

Anonymous 123:
Here is code close to what you need. You will have to modify it.

https://www.youtube.com/watch?v=TlrQLbSTgpQ

Anonymous said...

Hi Anonymous reply to anonymous 123 ...That video just shows the normal remote info and how the library is used. It does NOT show how to use the remote as a keypad and collect 123 and the send using a # (Like a mobile phone dial pad).
Did I miss something in the video ?

Does somebody please have an example of how to change this awesome library of Ken's to work like a dialpad or remote keypad where you can type in numbers like 123 and then only send when a # is pressed ...like 123#

Please help

Anonymous said...

Do you have documentation of the KEYES remote control? Who manufactures it?

Anonymous said...

The name conflicts with the IRremote in the arduino library RobotIRremote.

Unknown said...

about RobotIRremote see https://github.com/arduino/Arduino/issues/1909 not that has been any progress.

Unknown said...

i tried the demo example and it gave me this error:

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

Anonymous said...

Hi Ken,

I have a SEN-10266
IR Receiver Diode - TSOP38238 from Sparkfun. I am trying to capture IR codes from my remote using an Arduino UNO R3. I have the ground and power from the IR receiver connected to the Arduino and the "out" from the receiver going to pin 11 (PWM). I believe that is the pin you specified in your sketch. Anyways I cannot see any codes coming across the serial monitor after I upload the sketch. Is it possible I am using the wrong receiver? I looked at the data sheet for the receiver and believe I have it hooked up correctly. Please advise. Thank you very much!
Shawn.

Anonymous said...

Hi,

Very good work this library!!

I am trying to control a Sharp Aquods TV, I can perfertly power on, but i can´t power off it.

I do it, with raw codes like this:

Raw (32): 13772,300,1800,300,750,300,700,350,700,300,750,300,750,300,1800,300,1800,300,750,300,1750,300,750,300,750,300,750,300,1800,300,750,300,

I think that, to power off it, i must have mover raw samples.

How can I get more raw samples?? I modify RAWBUF in irremote.h but it doesn´t work.

Thanksss

sinaku said...

sir this is NANDEESH, COULD ANY ONE PLEASE TELL ME WHICH PROTOCOL IS USED TO FIND THE SIGNAL COMING FROM THE 24 KEYS RGB LED REMOTE, I HAVE AN URGENT PROJECT OVER THAT.

[email protected]

Unknown said...

Hello Ken,

Thank you for making complicated things simple.

I have started a project where holding down a button is necessary. Suppose I'm holding down a button and a LED is on until I release the button. I'm using NEC 1 IRC that sends a repeat code (0xFFFFFFFF) after the first press. I've written the code as you instructed.

void loop() {
if (irrecv.decode(&results)) {
if (results.value == 0x40BF18E7) {
digitalWrite(5,HIGH);
irrecv.resume();
}
}
}

I think you can see mistake I've done. Please help me using the repeat code. I would be thankful.

Anonymous said...

void loop() {
if (irrecv.decode(&results)) {
if (results.value == 0x40BF18E7) {
digitalWrite(5,HIGH);}
else
{
digitalWrite(5,LOW);}
irrecv.resume();
}
}
}

Unknown said...

Thank you anonymous.
But this code is not going to do what I want. Look at your code. When I will press the button, the remote will send 0x40BF18E7 once and the LED will be turned on very briefly because second time the remote will send repeated 0xFFFFFFFF and LED will remain low. :)

Unknown said...

I know that this is an older project, But I am using to make a device that with one keypad I can change multiple TV's to different channels. I have all of my code done. Then I noticed that this library is set up to only use PIN 3 to output. I am a somewhat novice coder. I know a bit, but I just wanted to find out if there was somewhere that I can add an arguement to IRsend to set a pin number for each command?

-Thank you in advance for any help!

Unknown said...

I am Unknown from above... I am also trying to get this to work on a Due. It seems it does not like the timer function, but im not sure. Any help there would be appreciated. Even just porting the send NEC to work on multiple outputs on the Due would be awesome!

Xavier said...

When I try to compile the receiver script I get the error:
"\libraries\RobotIRremote\IRremoteTools.cpp:5: error: 'TKD2' was not declared in this scope".
Any idea?
Regards

Ingmar Arvidsson said...

I am trying to create an IR-controlled RGBW-led strip controller using an Arduino micro.
This works almost perfect. The only problem is that one of the LED-channels behavs funny.
I have connected the channels in the following way;
#include
const int RECV_PIN = 11;
const int WHITE = 10;
const int BLUE = 9;
const int GREEN = 6;
const int RED = 5;
According to all information I can find this should function OK but the GREEN channel - 6 only give out values 0 or 255 all other channels work OK being able to control in the range 0-255.
If I comment out all "IR-code" then channel 6 also work OK.
There must be something with Timers or Interrupts but I can not understand why only ch6 is affected and not also ch5 since they are coupled to the same timer.
I am using the IR-library as is without any changes and also pinMode(ch, OUTPUT) + analogWrite().
I am using the delay()-function but a change to instead use loops with millis() did not help.
What is going wrong? Any hints would be much appreciated.

Unknown said...

Great post! I got here after use one of your codes (the IRecord.c).

For those who are having problem with compilation of the code: try to delete the folder "RobotIRremote" that is localized on your Arduino instalation folder (usualy: C:\Program Files (x86)\Arduino\libraries). This will solve the problem.

Unknown said...

Hi,

I have this error:
int RECV_PIN = TKD2; // the pin the IR receiver is connected to

I new and I don't know how I can do. Only I install the library and write the code:

#include

int RECV_PIN = 2;
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
}
}

Thanks for your great work!!!

Scuba_2 said...

Hi
I'm new to this and really like theIR library .
I wondered if you could answer a question?
When I play an IR code in Irecord on Arduino uno , I get 5ma going to the Led ( with no resistor in line)
However when I play a code with Irsend demo I get 10 ma at the led with no resistor?
I know the pins should be able to give out around 40ma with digitalWrite HIGH. But I can only assume current goes down as pwm frequency goes up?
Sorry in advance if this is a stupid question , but I can't find any info on it.
Many thanks Paul

Scuba_2 said...

Has anyone else noticed the sparkfun error?
https://learn.sparkfun.com/tutorials/ir-control-kit-hookup-guide

It took me ages to realise , they are taking the transmit code bush button to Gnd it should a pull down resistor fron pin 12 to Gnd then you apply 5v to pin 12 the transmit code!

Unknown said...

Have somebody try to decode airconditiner remote control for the airconditioner brand "carrier"..i really need the code..

Unknown said...

Please help me..i need this ASAP...

Anonymous said...

Which brand of carrier?
Model number?
Serial number?

Lucas Eng Elétrica UFBA said...

Hi guys, in order to send Samsung codes from Arduino, you must use the functio sendraw, with details of carrier frequency as well as the length of the vectors.

Afzol Miah said...

hi why doesnt anything seem to work for me:( help please

Bertran said...

C:\ARDUINO\arduino-1.0.6\libraries\RobotIRremote\IRremoteTools.cpp:5: error: 'TKD2' was not declared in this scope


I have this problem.

Scuba_2 said...

Can anyone tell me how to change the IR out pin from pin 3 ? Soft serial uses pin 2 and 3 so I need to use a different output pin.

Wisar said...

This is a great library. Unfortunately I have upgraded my computers and can no longer compile with it! I get the message
/Applications/Arduino.app/Contents/Resources/Java/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.

What have I done (or not done)?

Wisar said...

Finally found a post that gave me a solution to my problem from above. Turns out that 1.5.8 of the Arduino IDE comes with a library (RobotIRremote) that collides with this library. Delete that directory from the Arduino distribution installed library folder and I am good to go.

Anonymous said...

Wisar: Thanks for posting the solution. I wish more people did that.

Anonymous said...

Hi,
I have just downloaded the library and tried all the examples without success.
Here are the errors:
1) IR record: IRsend does not have name a type
2) IRrecvDemo: IKD2 was not declared in this scope
3) IRrecvDump: LG was not declared in this scope
4) IRrelay: 2)
5) IRsendDemo: as 1)
6) IRtest: expect class name (Related to IRsend?)
7) IRtest1: as 1)
8) JVCPanasonicSendDemo: as 1)

I am using an Arduino Mega 2560.

I also tried copying the contents of the library files from the recent posts, with no difference.

IRrecv is being recognised as a class.

I would love to know if there is something I have overlooked!

David

Anonymous said...

Wisar was spot on.
I removed RobotIRremote and all the errors stopped.
On a new point my Panasonic plasma buttons are not recognised as a type.
Has anyone had any success in controlling the plasmas?
I have read that the carrier frequency is a very specific 37.6 KHz?

David

Anonymous said...

Hello Ken,
Thank you for the Infra red library.
It works very well on a wide range of remotes.
I am having problems with a Panasonic plasma (carrier frequency 36.7?) and have been studying the contents of your Timer_Config_KHz routine in IRremoteInt.h.
I have been able to follow the procedure up to the point where OCRnA is set to pwmval/3
What does this do? Unfortunately this method is not detailed in your 1st rate tutorial.

David

Unknown said...
This comment has been removed by the author.
bart said...

Hello Ken, thanks for writing this much used arduino library. However could you provide support for using the Arduino Pro Micro? It's the atmega32u4. Thanks!

Anonymous said...

quick question ...
is it somewhat possible to simply wait for a handful IR codes .. and if they happen execute a CURL or REST command ?

Unknown said...

Hi Ken i am 13 jears old and don't know how to write an arduino code. And what i want is a arduino sketch that allows me to record an IR signal and re-transmit it with a button. How am i supposed to do that? Because i don't know how to program it.
Thanx for your help.

Bobalong said...

I cannot get the sample receive code to compile. I get the following:

Arduino: 1.5.8 (Linux), Board: "Arduino Nano, ATmega328"

Robot IR Remote/IRremoteTools.cpp.o: In function `resumeIRremote()':
/opt/arduino-1.5.8/libraries/RobotIRremote/src/IRremoteTools.cpp:10: multiple definition of `irrecv'
sketch_jan18a.cpp.o:/opt/arduino-1.5.8/hardware/arduino/avr/cores/arduino/HardwareSerial.h:109: first defined here
Robot IR Remote/IRremoteTools.cpp.o: In function `resumeIRremote()':
/opt/arduino-1.5.8/libraries/RobotIRremote/src/IRremoteTools.cpp:10: multiple definition of `results'
sketch_jan18a.cpp.o:/opt/arduino-1.5.8/hardware/arduino/avr/cores/arduino/HardwareSerial.h:109: first defined here
Robot IR Remote/IRremoteTools.cpp.o:(.data.RECV_PIN+0x0): multiple definition of `RECV_PIN'
sketch_jan18a.cpp.o:(.data.RECV_PIN+0x0): first defined here
collect2: error: ld returned 1 exit status
Error compiling.

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

If I remove either copy I get "not defined in this scope" type errors.

Unknown said...

hai. me name is yogeesh i downloaded the IRremote library and renamed and followed all procedure to copy it to aurdino librearies and in aurdino when i compile the example code of IRrecvDemo ,it is showing error that
This report would have more information with
"Show verbose output during compilation"
enabled in File > Preferences.
Arduino: 1.0.6 (Windows 7), Board: "Arduino NG or older w/ ATmega8"
C:\Program Files (x86)\Arduino\libraries\RobotIRremote\IRremoteTools.cpp:5: error: 'TKD2' was not declared in this scope




so please help me anyone to rectify the problom....

berdux said...

hey! that is a very useful library for many projects!

Is there any way to make it work with multiple receivers on a single arduino?

Ajax said...

Hai ken thanks for your library, i am stuck with sending raw codes to my dth box.

i am getting different outputs to the same button, here's the raw codes...

Raw (18): 7536 250 -850 250 -2550 300 -650 300 -2700 300 -1200 250 -1200 300 -1600 300 -1050 300 .
77A3660E, 32);

UNKN
Raw (18): 24074 250 -850 250 -2550 300 -650 300 -2700 250 -1200 300 -1200 300 -1600 300 -1050 300 .
77A3660E, 32);

UNKN
Raw (18): 21816 300 -800 300 -2550 250 -700 250 -2700 300 -1200 300 -1200 250 -1650 250 -1100 250 .
77A3660E, 32);


and I am sending the codes as follows:

irsend.sendRaw(rawCodes[0], 18, 38);

assuming rawCodes is an array of unsigned int.

please reply

Unknown said...

wat type of arduino can I buy?

Anonymous said...

#martin
hlw could any1 plz any 1 send me d complete hexapod code including library section of CHUNGHOP RM-68E universal tv remote. ineed dat badly

Franz said...

Hi Ken,

I forked the library and added the protocol used by my Whynter air conditioner. I have created a pull request in GitHub, feel free to add it to the general codebase if you think it's appropriate.

Francesco

Emil said...

Hi

Can someone help me?
Can someone instal:
https://play.google.com/store/apps/details?id=net.exunity.microlab.remote&hl=pl

and read code?
it is probably in NEC
remote for microlab solo 7c

Anonymous said...

Trying to control a Flameless LED candle with this. I can capture the remote codes but when I play them back nothing happens. I can see that sometimes when it plays back the receive sensor gets a new code but it is always blank. I have printed out the code being sent and it matches that being received but it never works.

I've also taught my Harmony Remote how to control the candles and that works. I can then point that at the sensor to read the code and it clearly is the same as the one being sent from the actual remote so it is capturing properly.

Any thoughts? Could I need to boost the IR LED? The candle is right next to it.

thanks

scott

Elvis said...

Hi. thanks for the information and insight on this project cos i am actually working on a project related to this.Basically i am working a robotic luggage for my project and i think that this method will be of help.But do you have more light to throw on how i can go about it to make it a reality.I will need more advice from you.Please you dont mind could you mail me on [email protected]. i will appreciate it.Thanks

Unknown said...

Hello, I am new to Arduino and amazed on the capabilities. I have a project that I would like you input in. Here is what I am trying to accomplish. I have an Arduino yun and I have an eRod motorized curtain drapery that I would like to be able to control it with the Arduino. The curtain rod uses a IR remote and I like to be able to close and open using the arduino and control it from anywhere. Any suggestions on how I can do this or point me to any resources. Any help would be greatly appreciated.

mchp said...

Hi!
Thank you for very useful library!
I had a few issues while using it but I've handled them myself except one: how to make ATmega8 work with timer 2? My sketch works perfect with ATmega168 (it uses timer 2) but I need it to work with ATmega8. Is there any way to fix that? I see that there is a possibility to choose between timers for different controllers (in file RC5Int.h) except ATmega8. Why is that?

Shashwat Khoont said...

Hey this is great work. Can you please suggest me a way to transmit data using IR between two Arduino boards? Both having an LED and a receiver.

Thanks.

Rossos said...

​I've Made it! (sry no pictures)

One small remark: if you have Sony or some other R5/R6 protocol Infrared remote control, which apparently sends their signal 3 times instead of using checksum last bits, you may need to open up file manually and go all the way down and adjust the RAWBUF constant. By default it is 100, but my codes were of the size 182. I've set the constant to 192 (higher values were causing crashes on my Arduino Nano) and everything started working.

Anonymous said...

How to LG : 6710V00090N ?

Unknown said...

plsssssssssssss help me plsssssssssssssssssssssssss...



your library stops working on standalone atmega8 after some random time............pls help me plssssssss

link to the problem is

http://forum.arduino.cc/index.php?topic=323529.0

Unknown said...

plsssssssssssss help me plsssssssssssssssssssssssss...



your library stops working on standalone atmega8 after some random time............pls help me plssssssss

link to the problem is

http://forum.arduino.cc/index.php?topic=323529.0

Unknown said...

hello help me pls i use this code:
#include

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


and have this:
C:\Users\goga\Documents\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:\Users\goga\Documents\Arduino\libraries\RobotIRremote
Not used: C:\Users\goga\Documents\Arduino\libraries\Arduino-IRremote-master
Not used: C:\arduino-nightly\libraries\Arduino-IRremote-master
Not used: C:\arduino-nightly\libraries\RobotIRremote
Ошибка компиляции.

how to fix it??

Unknown said...

hello help me pls i use this code:
#include

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


and have this:
C:\Users\goga\Documents\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:\Users\goga\Documents\Arduino\libraries\RobotIRremote
Not used: C:\Users\goga\Documents\Arduino\libraries\Arduino-IRremote-master
Not used: C:\arduino-nightly\libraries\Arduino-IRremote-master
Not used: C:\arduino-nightly\libraries\RobotIRremote
Ошибка компиляции.

how to fix it??

Anonymous said...

Google:

'TKD2' was not declared in this scope

Amit said...

I am facin a funny problem.
Remote is Panasonic Air Conditioner.
ON/OFF, Mode,Fan speed works.
result of Temprature up and down is same as last result, i.e. 'result' is not altered.

Any button in timer section a has no result.
Any help?

Shashwat Khoont said...

Hey this was really helpful. Thank You.

I am new to Arduino and I am making an IR interface between two Arduinos. I want to send Hex codes between the two boards, which can be later read on the serial moniter. Can you help me please?

Thanks.

«Oldest ‹Older   601 – 800 of 895   Newer› Newest»