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.

876 comments:

«Oldest   ‹Older   401 – 600 of 876   Newer›   Newest»
Anonymous said...

@Lauszus
Thanx for the fast answer!
Do you mean i should "erase" the class IRSend (did it with comment) like:
/*
* IRremote
* Version 0.1 July, 2009
* Copyright 2009 Ken Shirriff
* For details, see http://arcfn.com/2009/08/multi-protocol-infrared-remote-library.htm http://arcfn.com
*
* Interrupt code based on NECIRrcv by Joe Knapp
* http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1210243556
* Also influenced by http://zovirl.com/2008/11/12/building-a-universal-remote-with-an-arduino/
*/

#ifndef IRremote_h;
#define IRremote_h;

// The following are compile-time library options.
// If you change them, recompile the library.
// If DEBUG is defined, a lot of debugging output will be printed during decoding.
// TEST must be defined for the IRtest unittests to work. It will make some
// methods virtual, which will be slightly slower, which is why it is optional.
// #define DEBUG
// #define TEST

// Results returned from the decoder
class decode_results {
public:
int decode_type; // NEC, SONY, RC5, UNKNOWN
unsigned long value; // Decoded value
int bits; // Number of bits in decoded value
volatile unsigned int *rawbuf; // Raw intervals in .5 us ticks
int rawlen; // Number of records in rawbuf.
};

// Values for decode_type
#define NEC 1
#define SONY 2
#define RC5 3
#define RC6 4
#define UNKNOWN -1

// Decoded value for NEC when a repeat code is received
#define REPEAT 0xffffffff

// main class for receiving IR
class IRrecv
{
public:
IRrecv(int recvpin);
void blink13(int blinkflag);
int decode(decode_results *results);
void enableIRIn();
void resume();
private:
// These are called by decode
int getRClevel(decode_results *results, int *offset, int *used, int t1);
long decodeNEC(decode_results *results);
long decodeSony(decode_results *results);
long decodeRC5(decode_results *results);
long decodeRC6(decode_results *results);
}
;

/*
// Only used for testing; can remove virtual for shorter code
#ifdef TEST
#define VIRTUAL virtual
#else
#define VIRTUAL
#endif

class IRsend
{
public:
IRsend() {}
void sendNEC(unsigned long data, int nbits);
void sendSony(unsigned long data, int nbits);
void sendRaw(unsigned int buf[], int len, int hz);
void sendRC5(unsigned long data, int nbits);
void sendRC6(unsigned long data, int nbits);
// private:
void enableIROut(int khz);
VIRTUAL void mark(int usec);
VIRTUAL void space(int usec);
}
;
*/
// Some useful constants

#define USECPERTICK 50 // microseconds per clock interrupt tick
#define RAWBUF 76 // Length of raw duration buffer

// Marks tend to be 100us too long, and spaces 100us too short
// when received due to sensor lag.
#define MARK_EXCESS 100

#endif

Lauszus said...

#Anonymous
It's more easy than that, just don't create the instance in your code like so:
https://github.com/TKJElectronics/Arduino-IRremote/blob/master/examples/IRsendDemo/IRsendDemo.ino#L11
Then you can always to use the pin for something else.

You can also just change the pin to 9 - just uncomment the following line: https://github.com/TKJElectronics/Arduino-IRremote/blob/master/IRremoteInt.h#L62

But yes, you could also delete the class, but it's not necessary.

- Lauszus

Anonymous said...

@Lauszus

wow...u r helping me really a lot!!!
THANX! option 2 is fine for me, i think! because, when i just don't create the IRSend i cannot use Pin3 fpr PWM (analogWrite()). Is this possible or is there a mistake i make?
i try to post my example tomorrow, cause here in austria it's 2 am :)

gn8, til tomorrow:)
Martin

Anonymous said...

@Lausus

this is my code i talked about...
if i increase the value LEDHELLIGKEIT there is only one short blink when it passes 255.


#include



int RECV_PIN = 11;
int LED = 3;
int LEDHELLIGKEIT = 0;

IRrecv irrecv(RECV_PIN);

decode_results results;

void setup()
{
pinMode(LED,OUTPUT);
digitalWrite(LED,HIGH);
Serial.begin(9600);
irrecv.enableIRIn(); // Start the receiver
}

void loop() {
if (irrecv.decode(&results)) {
Serial.println(results.value);
if(results.value == 22058)
{
Serial.println("UP!");
LEDHELLIGKEIT =LEDHELLIGKEIT +1;
analogWrite(LED,LEDHELLIGKEIT);

}
if(results.value == 13866)
{
Serial.println("DOWN!");
LEDHELLIGKEIT =LEDHELLIGKEIT -1;
analogWrite(LED,LEDHELLIGKEIT);
}
Serial.println(LEDHELLIGKEIT);
irrecv.resume(); // Receive the next value
}
}


what do u think?

Lauszus said...

#Anonymous
You can't use pwm on pin 3 while using pin 11 for receiving, as they both use timer2. See the following page: http://arduino.cc/playground/Main/TimerPWMCheatsheet

Try to use timer1 by uncomment the following line: https://github.com/TKJElectronics/Arduino-IRremote/blob/master/IRremoteInt.h#L62 and it should work just fine or use another pin for pwm than pin 3.

Regards
Lauszus

Anonymous said...

p.s.: if i'm changing the pin to 5 it works perfect...this is why i thought pin3 is defined as output for the ir-led anyway when i call remote.h

Anonymous said...

wow...i NEVER thought about the timer! also i think i have a pretty old version of remote...because i cannot find the line :)

Lauszus said...

#Anonymous
You can just download my fork: https://github.com/TKJElectronics/Arduino-IRremote
I have sent a pull request to Ken, but he hasn't answered yet (https://github.com/shirriff/Arduino-IRremote/pull/7).

Regards
Lauszus

Alvaro said...

Hi wen i try compiling de IRsendDemo, the IRremote.cpp have many errors like:

Error Compiling



IRremote/IRremote.cpp.o: In function `IRrecv':
/Applications/Arduino.app/Contents/Resources/Java/libraries/IRremote/IRremote.cpp:217: multiple definition of `IRrecv::IRrecv(int)'
IRremote.cpp.o:IRremote.cpp:227: first defined here
IRremote/IRremote.cpp.o: In function `IRrecv':
/Applications/Arduino.app/Contents/Resources/Java/libraries/IRremote/IRremote.cpp:217: multiple definition of `irparams'
IRremote.cpp.o:IRremote.cpp:227: first defined here
IRremote/IRremote.cpp.o: In function `IRrecv':
/Applications/Arduino.app/Contents/Resources/Java/libraries/IRremote/IRremote.cpp:217: multiple definition of `IRrecv::IRrecv(int)'
IRremote.cpp.o:IRremote.cpp:227: first defined here
IRremote/IRremote.cpp.o: In function `IRrecv::resume()':
/Applications/Arduino.app/Contents/Resources/Java/libraries/IRremote/IRremote.cpp:332: multiple definition of `IRrecv::resume()'
IRremote.cpp.o:IRremote.cpp:342: first defined here
IRremote/IRremote.cpp.o: In function `IRrecv::decodeNEC(decode_results*)':
/Applications/Arduino.app/Contents/Resources/Java/libraries/IRremote/IRremote.cpp:383: multiple definition of `IRrecv::decodeNEC(decode_results*)'
IRremote.cpp.o:IRremote.cpp:393: first defined here
IRremote/IRremote.cpp.o: In function `IRrecv::decodeSony(decode_results*)':
/Applications/Arduino.app/Contents/Resources/Java/libraries/IRremote/IRremote.cpp:431: multiple definition of `IRrecv::decodeSony(decode_results*)'
IRremote.cpp.o:IRremote.cpp:441: first defined here
IRremote/IRremote.cpp.o: In function `IRrecv::getRClevel(decode_results*, int*, int*, int)':
/Applications/Arduino.app/Contents/Resources/Java/libraries/IRremote/IRremote.cpp:478: multiple definition of `IRrecv::getRClevel(decode_results*, int*, int*, int)'
IRremote.cpp.o:IRremote.cpp:488: first defined here
IRremote/IRremote.cpp.o: In function `IRrecv::decodeRC5(decode_results*)':
/Applications/Arduino.app/Contents/Resources/Java/libraries/IRremote/IRremote.cpp:517: multiple definition of `IRrecv::decodeRC5(decode_results*)'
IRremote.cpp.o:IRremote.cpp:527: first defined here
IRremote/IRremote.cpp.o: In function `IRrecv::decodeRC6(decode_results*)':
/Applications/Arduino.app/Contents/Resources/Java/libraries/IRremote/IRremote.cpp:552: multiple definition of `IRrecv::decodeRC6(decode_results*)'
IRremote.cpp.o:IRremote.cpp:562: first defined here
IRremote/IRremote.cpp.o: In function `IRrecv::decode(decode_results*)':
/Applications/Arduino.app/Contents/Resources/Java/libraries/IRremote/IRremote.cpp:341: multiple definition of `IRrecv::decode(decode_results*)'
IRremote.cpp.o:IRremote.cpp:351: first defined here
IRremote/IRremote.cpp.o: In function `__vector_15':
/Applications/Arduino.app/Contents/Resources/Java/libraries/IRremote/IRremote.cpp:264: multiple definition of `__vector_15'
IRremote.cpp.o:IRremote.cpp:274: first defined here
IRremote/IRremote.cpp.o: In function `IRrecv::blink13(int)':
/Applications/Arduino.app/Contents/Resources/Java/libraries/IRremote/IRremote.cpp:252: multiple definition of `IRrecv::blink13(int)'
IRremote.cpp.o:IRremote.cpp:262: first defined here
IRremote/IRremote.cpp.o: In function `IRrecv::enableIRIn()':
/Applications/Arduino.app/Contents/Resources/Java/libraries/IRremote/IRremote.cpp:224: multiple definition of `IRrecv::enableIRIn()'
IRremote.cpp.o:IRremote.cpp:234: first defined here
IRremote/IRremote.cpp.o: In function `IRsend::enableIROut(int)':
...

my Arduino is a MEGA 2560 and i alredy change de output pin 3 to 9 but i still get this errors can anyone helpme??

Tanks and sorry my english i am not native...

C. Weeks said...

Hi Ken,

First off, thanks for all the hard work on building this library, the documentation and even the examples. You've saved me many, many days (weeks? months even?) of research.

Now for the issue: This is my first Arduino project and I'm still tinkering with the IRremote examples that you've bundled with the library and, while IRsendDemo works as coded, I can't seem to get IRrecord to work.

Hardware:
Arduino Uno R3
IR receiver breakout board - http://www.sparkfun.com/products/8554
Max Power IR LED Breakout kit - http://www.sparkfun.com/products/10732

Luckily the device I'm trying to operate uses sony codes and 0xA90 in the IRsendDemo works perfect.
I switched over to the IRrecord sketch and the serial output is as follows:

Received SONY: A90
Received SONY: A90
Received SONY: A90
Received SONY: A90

When I hit the button, the IR LED lights up (checked with my phone) but no dice. I've tried copy/pasting the send code with the For statement directly from the IRsendDemo to the IRrecord Thinking it might be a timing issue but still nothing.

If it helps here's a dump of the button press:
A90
Decoded SONY: A90 (12 bits)
Raw (26): -25430 2500 -500 1300 -450 700 -500 1300 -450 700 -500 1300 -450 700 -500 700 -450 1300 -500 700 -450 700 -450 700 -500 700
A90
Decoded SONY: A90 (12 bits)
Raw (26): -13802 2500 -450 1350 -450 700 -450 1350 -450 700 -450 1350 -450 700 -450 700 -500 1300 -500 650 -500 700 -450 700 -500 650
A90
Decoded SONY: A90 (12 bits)
Raw (26): 4982 2500 -450 1350 -450 700 -500 1300 -450 700 -500 1300 -450 700 -500 700 -450 1300 -500 700 -450 700 -450 700 -500 700


Any chance you can shed some light on what I'm missing?

Thanks again,
Weeks

Joe Duper said...

Hello,

I appreciate the blog and all of the comments.

I have quick question. My application requires that I send a pause signal to my Cisco CHS 435 HD DVR (Verizon Set-top-box). I could not find any information on the LIRC.

I used the IrDump and got the following results:


Press pause once:

Could not decode message
Raw (36): -27894 9050 -4450 500 -4500 500 -4500 500 -4500 500 -4500 500 -4500 500 -2200 550 -2200 550 -2200 550 -2200 550 -2200 550 -2200 550 -2200 550 -2200 500 -2250 500 -2250 500 -2250 500

Press a second time:

Could not decode message
Raw (36): 30068 9050 -4500 500 -4500 500 -4500 500 -4450 550 -4450 550 -4450 550 -2200 550 -2200 500 -2250 500 -2250 500 -2250 500 -2250 500 -2250 500 -2250 500 -2250 500 -2250 500 -2250 500


Hold button down:

Decoded NEC: FFFFFFFF (0 bits)
Raw (4): -21914 9000 -2200 550
FFFFFFFF


I saw in the blog you mention the special code for holding the button down, so I just ignored that.

In order to attempt to transmit the raw data I implemented the following:

#include

IRsend irsend;

void setup() {

}

void loop() {
unsigned int Pause[36]={-27894,9050,-4450,500,-4500,500,-4500,500,-4500,500,-4500,500,-4500,500,-2200,550,-2200,550,-2200,550,-2200,550,-2200,550,-2200,550,-2200,550,-2200,500,-2250,500,-2250,500,-2250,500};
unsigned int Pause2[36]={30068,9050,-4450,500,-4500,500,-4500,500,-4500,500,-4500,500,-4500,500,-2200,550,-2200,550,-2200,550,-2200,550,-2200,550,-2200,550,-2200,550,-2200,500,-2250,500,-2250,500,-2250,500};

irsend.sendRaw(Pause,36,36);
delay(2000);
irsend.sendRaw(Pause2,36,36);
delay(2000);


I can verify that the LED is transmitting using a cell phone camera, but I have no action from the DVR receiver.

Any thoughts out there?

Thanks a ton in advance.

-Joe

Brewin' Brian said...

I noticed several people in the comments section have wanted to use this library to control their air conditioners/heat pumps. These systems generally use very long IR codes to transmit all of the state information (temp, fan, mode, etc.) at each button press.

Ken's library is amazing, but it is not set up to handle extremely long raw IR codes. I managed to work out some easy changes to the library that allowed me to control my new Mistubishi "Mr. Slim" split system.

Following the advice of earlier commenters, I increased the length of RAWBUF in . However, I noticed that no matter how big I made RAWBUF, the codes for the Mr. Slim were filling the buffer. For example, if I defined RAWBUF as 175, I'd get 175 marks using the IRrecvDump demo. Additionally, if I increased RAWBUF past a certain point (which turned out to be 255… getting any ideas?), I would get nonsensical output.

After digging around in the library for a while I noticed that the state machine for gathering the raw codes used a value rawlen as a counter for the entries in rawbuf. In rawlen is defined in the following code snippet:

// information for the interrupt handler
typedef struct {
 uint8_t recvpin;           // pin for IR data from detector
 uint8_t rcvstate;          // state machine
 uint8_t blinkflag;         // TRUE to enable blinking of pin 13 on IR processing
 unsigned int timer;     // state timer, counts 50uS ticks.
 unsigned int rawbuf[RAWBUF]; // raw data
 uint8_t rawlen;         // counter of entries in rawbuf
}
irparams_t;

Aha! Since rawlen is is an unsigned 8 bit integer, rawlen couldn't be greater than 255. That's why I was getting garbage when I increased RAWBUF to be any bigger than 255.

Sooo, after all that, it's an easy fix to read -extremely- long codes. Simply change rawlen to a 16 bit integer as follows:

uint16_t rawlen;         // counter of entries in rawbuf

Then, if you also increase the size of RAWBUF, you've got a gigantic buffer for storing marks. My Mr. Slim system ended up using 292(!) marks in each button press.

I hope this helps those of you who couldn't get your AC's under control. Stay cool!

vasant said...

Hi,
I am not able to compile when I use a ATMEGA8 Micro. Any Solution?

Vasant

C. Weeks said...

Can't really do much for you without knowing what errors you are getting.

AleXX® said...

Hi all!
I've read trough the whole discussion but I am still stuck with my Panasonic TV's Remote Control.

I am using Arduino UNO R3, TKJElectronics-Arduino-IRremote-937ce48.zip libraries and the remote control I would like to "copy" is the Panasonic EUR7737Z50 (see: http://www.panasonicshop.sk/en/plasma-tv/458-eur7737z50.html)

My problem is that when i load the example sketch "IRrecvDump" and I press the power button I receive the following on serial:
F61E2A57
Unknown encoding: F61E2A57 (32 bits)
Raw (100): -27978 3450 -1750 400 -450 450 -1250 450 -400 500 -400 450 -400 450 -450 400 -450 450 -400 450 -400 450 -450 400 -450 450 -400 450 -400 450 -1300 400 -450 450 -450 400 -400 500 -400 450 -400 450 -450 400 -450 450 -400 450 -400 450 -1300 400 -450 450 -400 450 -450 450 -400 450 -400 450 -450 400 -450 450 -400 450 -1300 400 -400 500 -1250 450 -1300 400 -1300 450 -1300 400 -450 450 -450 400 -1300 400 -450 450 -1300 400 -1300 450 -1300 400 -1350 400 -450 450 -1250 450

I need to be able to get just the "TV" and "AV" button codes and play them back when I need this...

For the TV button I get:

1C42833F
Unknown encoding: 1C42833F (32 bits)
Raw (100): -23724 3450 -1750 400 -450 450 -1250 450 -450 400 -450 450 -450 400 -450 400 -450 400 -450 450 -450 400 -450 400 -450 450 -400 450 -450 400 -1300 450 -450 400 -450 400 -450 400 -450 450 -450 400 -450 400 -450 400 -450 450 -450 400 -1300 450 -400 450 -1300 400 -450 450 -450 400 -450 400 -450 400 -450 450 -450 400 -450 400 -450 450 -400 450 -450 400 -1300 450 -1300 400 -450 400 -450 450 -400 450 -1300 400 -450 450 -400 450 -1300 450 -1300 400 -450 400 -1350 400


and for the AV button I get:
1DA66E1F
Unknown encoding: 1DA66E1F (32 bits)
Raw (100): 22960 3450 -1750 400 -450 450 -1300 400 -450 400 -450 450 -400 450 -450 400 -450 400 -450 450 -400 450 -450 400 -450 400 -450 450 -450 400 -1300 450 -400 450 -450 400 -450 400 -450 450 -450 400 -450 400 -450 400 -450 450 -450 400 -1300 450 -400 450 -400 450 -400 450 -450 450 -400 450 -450 400 -450 400 -450 450 -1300 400 -450 400 -1350 400 -450 400 -450 450 -400 450 -400 450 -450 400 -1350 400 -400 450 -1300 450 -450 400 -450 400 -450 400 -450 450 -1300 400



any help would be appreciated...

Thank you!!

Alessandro - Italy

Lauszus said...

@AleXX®
It look like your marks a bit shorter than what the code were design for.
Try setting PANASONIC_BIT_MARK to 450 (https://github.com/TKJElectronics/Arduino-IRremote/blob/master/IRremoteInt.h#L126) and see if it works.
You could also try to increase the tolerance (https://github.com/TKJElectronics/Arduino-IRremote/blob/master/IRremoteInt.h#L140).

Regards
Lauszus

AleXX® said...

@ Lauszus:
Thank you for your great help in so little time :)
I've made some tests and I found out the only change needed to make the stuff work is to change the line 140 of the file IRremoteInt.h (https://github.com/TKJElectronics/Arduino-IRremote/blob/master/IRremoteInt.h#L140)

from: #define TOLERANCE 20
into: #define TOLERANCE 35

I run some tests and I found that setting the Tolerance to 34 is enough almost every time, but with 35 it seems 100% ok

I also tried to collect some data from the IR and "manually" find a good set of values for the lines

#define PANASONIC_HDR_MARK 3502
#define PANASONIC_HDR_SPACE 1750
#define PANASONIC_BIT_MARK 502
#define PANASONIC_ONE_SPACE 1244
#define PANASONIC_ZERO_SPACE 400

but I get no luck there... I tried to find the average values but I had no success in identifying the IR Brand/Address/Value until I raised the tolerance...

Thank you again!
Bye!!

p.s. Just to let you know...
I am building a system able to detect my 2yrs old little daughter while she watches TV tooo close to it and then pull out a blank screen (AV Input...) until she gets far enough (TV button to restore the previous state...)

Thank you again!
Bye!!
Alessandro - Italy

sandeep_clu said...

hey ..!! great work..!! but here i m suffering a bit..
i am trying to take output in LCD by using your library.. the code is here..


#include
#include


LiquidCrystal lcd(12, 11, 7, 6, 5, 4);

const int irReceiverPin = 2;
IRrecv irrecv(irReceiverPin);
decode_results results;

void setup() {
lcd.begin(16, 2);
lcd.print("IR Decoder");

irrecv.blink13(true);
irrecv.enableIRIn();
}


void showIRProtocol(decode_results *results)
{
switch(results->decode_type) {
case NEC:
lcd.print("NEC");
break;
case SONY:
lcd.print("SONY");
break;
case RC5:
lcd.print("RC5");
break;
case RC6:
lcd.print("RC6");
break;
default:
lcd.print("Unknown");
break;
}


lcd.print(" ");
lcd.print(results->value, HEX);
lcd.print(" (");
lcd.print(results->bits);
lcd.print(")");
}

void loop() {

lcd.setCursor(0, 1);

if (irrecv.decode(&results)) {
showIRProtocol(&results);
irrecv.resume();
}
}

i got this code from
http://coopermaa2nd.blogspot.in/2011/03/14-lcd-ir-decoder.html?utm_source=feedburner&utm_medium=feed&utm_campaign=Feed:+CooperMaa+%28Cooper+Maa%29

every time wen i give some input from universal remote control.. it shows "unknown" i have tried for almost every brand IR remote..

Brad said...

I have been trying to use this code along with code for the Arduino motor shield. the two codes by their self work fine but when put together the motor shield does not work. could there be any conflicting pins or variables that might be interfering?

Lauszus said...

@Brad
Take a look at Kens other post:
http://www.arcfn.com/2009/07/secrets-of-arduino-pwm.html - see "Timers and the Arduino".

As the code uses timer2 (https://github.com/TKJElectronics/Arduino-IRremote/blob/master/IRremoteInt.h#L63) for sending you can't use pin 3 and 11 for pwm for the motorshield.

As the motorshield for Arduino (http://arduino.cc/it/Main/ArduinoMotorShieldR3) uses pin 3 and 11 for pwm, you have to use timer1 instead for the IR library.
Just uncomment the following line: https://github.com/TKJElectronics/Arduino-IRremote/blob/master/IRremoteInt.h#L62 and comment https://github.com/TKJElectronics/Arduino-IRremote/blob/master/IRremoteInt.h#L63, then connect your IR LED to pin 9 instead.

Regards
Lauszus

DRMED said...

Hi everyone,

While I was trying to compile the example sketches on the arduindo IDE 1.0 I got a missing Wprogram.h file referenced in the gameduino cpp code, some googling found the solution. In Arduino 1.0 IDE the file was renamed to Arduino.h so rename the header file WProgram.h in the GD.cpp to Arduino.h to fix the problem.

C. Weeks said...

Yeah, seems you have to do that for a lot of libraries since 1.0.

I'm working on a bit of a clone of Fall Deaf's WEUR and I had to modify that part of the code for about 4 different libraries and also had to modify the Ethernet library for the new syntax of EthernetServer, etc.

Probably would've been easier if I was actually a programmer. All I can really say is All Hail El Goog.

Ephron said...

I keep getting this error:

...\arduino-1.0\libraries\IRremote/IRremoteInt.h:91: error: 'RAWBUF' was not declared in this scope

I have no idea what this could be about, since I'm a C++-noob.
The examples do compile, however.

Ephron said...

Ok, last problem got solved.
defined RAWBUF in IRremoteInt.h with same value.
However, now pin 0 seems somehow affected by this algorithm.
How could this be possible, I can't find any link

Lauszus said...

@Ephron
It looks like you haven't added the library correctly. Try to use my forked version: https://github.com/TKJElectronics/Arduino-IRremote which works for Arduino 1.0.

Information on how to add the library can be found at the following page: http://arduino.cc/en/Guide/Environment#libraries

You shouldn't change any files, as the library is confirmed to work by many people, so if you get an error, then you have probably done something wrong!

Regards
Lauszus

Michael.Casson said...

I love this library! It was definitely easier than I was expecting. However, I find that I need to have six working hardware PWMs for my next project, and this library leaves me with only four on the atmega328, no matter which timer gets used.

I see that the modified library for the Teensy only disables one of the seven PWM pins. Would this library also work on an Arduino Leonardo (same atmega32u4)?

I have a Teensy 2.0, but I cannot use it in my final build since I need it to be a one-board design of my making. The teensy bootloader is not available to burn to a bare chip, so that's out.

I'm only asking since I don't have a Leonardo or other atmega32u4 breakout board yet to test. Thanks again for the awesome library!

K. said...

Michael: Sorry, I don't know if the Library works with the Leonardo. A lot of people have problems with the library using the timers they want to use for other things, and hopefully at some point I'll have time to sort this out. I haven't tried it with a Leonardo, but I expect it should work the same as on a Teensy. You could also ask pjrc.com, who did the Teensy port.

Anonymous said...

Can someone send me the library for arduino v1.0.1

Lauszus said...

Just go to the github: https://github.com/shirriff/Arduino-IRremote and press the button labeled "zip", extract the folder and then move the directory to your Arduino library folder.

Regards
Lauszus

Lauszus said...

@Michael.Casson
Take a look at the pinout: http://www.pjrc.com/teensy/pinout.html and http://arduino.cc/en/Hacking/PinMapping32u4
Your pwm pin is the located at PC7/OC4A, so it's pin 13 on the Arduino leonardo.

Regards
Lauszus

Michael Rogers said...

Okay guys, thanks.

I'm hesitant to bother PJRC about it, since it's not about his product. I've got a Leonardo ordered to develop on, so I'll just wait and see. If it doesn't work, I'll look more into it then. Either way, I'll report back on my findings.

Thanks again.

Mr Mase said...

Cheers for the library!

I've just got this working with my Samsung TV. I had to use the code improvements here to work with Samsung

http://www.maartendamen.com/2010/05/jeenode-infrared-project-part-1-getting-started/

And I also changed IRemote.cpp to work with my Atmega 1280 to use Pin 9 properly. Where it said:

pinMode(3, OUTPUT);
digitalWrite(3, LOW); // When not sending PWM, we want it low


To

#if defined (__AVR_ATmega1280__) || defined(__AVR_ATmega2560__)
pinMode(9, OUTPUT);
digitalWrite(9, LOW); // When not sending PWM, we want it low
#else
pinMode(3, OUTPUT);
digitalWrite(3, LOW); // When not sending PWM, we want it low
#endif

Mr Mase said...

TOP TIP: you can use your phone's camera to check if you IR LED is blinking :)

Greg said...

I haven't seen this one yet, so I figured I'd post it. This is the protocol for Philips RC-MM. My AT&T U-Verse receiver uses this protocol. Haven't figured out how to write the decode portion yet, but here's the transmit method:

void IRsend::sendRCMM(unsigned long data, int nbits, int pin) {
enableIROut(36, pin);
mark(RCMM_HDR_MARK, pin);
space(RCMM_HDR_SPACE, pin);
data = data << (32 - nbits);
unsigned long datax;
for (int i = 0; i < nbits; i+=2) {
datax = data & TOPTWOBITS;
if (datax == 0x00000000) {
mark(RCMM_DATA_MARK, pin);
space(RCMM_00_SPACE, pin);
}
else if (datax == 0x40000000) {
mark(RCMM_DATA_MARK, pin);
space(RCMM_01_SPACE, pin);
}
else if (datax == 0x80000000) {
mark(RCMM_DATA_MARK, pin);
space(RCMM_10_SPACE, pin);
}
else if (datax == 0xC0000000) {
mark(RCMM_DATA_MARK, pin);
space(RCMM_11_SPACE, pin);
}
data <<= 2;
}
mark(RCMM_DATA_MARK, pin);
space(RCMM_RPT_SPACE, pin);
}

Greg said...

Almost forget to timing parameters!

#define RCMM_HDR_MARK 417
#define RCMM_HDR_SPACE 278
#define RCMM_DATA_MARK 167
#define RCMM_00_SPACE 278
#define RCMM_01_SPACE 444
#define RCMM_10_SPACE 611
#define RCMM_11_SPACE 779
#define RCMM_RPT_SPACE 3360

Paul said...

Hi Ken,

Thanks for creating & sharing this library. I've been using the receiver functions & they've been very reliable and robust. I'm starting to make a list of IR codes for remotes I've been using. You can find it here: http://www.MegunoLink.com/Infrared_Codes_for_Common_Remotes

Michael Rogers said...

The IRremote library on github (b25accf as of moment of writing) worked for me on an Arduino Leonardo. I just had to:
#define TIMER_PWM_PIN 10
Thanks all!

David said...

I tried importing the library into an Arduino 1.0 sketch and after compileing I got the following errors:

In file included from sketch_jun13a.cpp:2:
C:\Program Files\arduino-1.0\libraries\IRremote/IRremoteInt.h:15:22: error: WProgram.h: No such file or directory
In file included from sketch_jun13a.cpp:2:
C:\Program Files\arduino-1.0\libraries\IRremote/IRremoteInt.h:87: error: 'uint8_t' does not name a type
C:\Program Files\arduino-1.0\libraries\IRremote/IRremoteInt.h:88: error: 'uint8_t' does not name a type
C:\Program Files\arduino-1.0\libraries\IRremote/IRremoteInt.h:89: error: 'uint8_t' does not name a type
C:\Program Files\arduino-1.0\libraries\IRremote/IRremoteInt.h:92: error: 'uint8_t' does not name a type

the only code i had was the #include statements and blank setup and loop methods. Could you shed some light on these errors?

Thanks in advance!

Michael Rogers said...

@David, Per the top of this page:
"Note for Arduino 1.0
I haven't had time to update the library yet, but several helpful people have told me that to use the library with Arduino 1.0, you need to change
#include
to
#include
in IRRemoteInt.h."

Michael Rogers said...

Hmm... it cut the important parts out of my last post (sanitized as tags), but the solution really is the first thing on this page.

Julez Stone said...

Hi Ken,

Im having real trouble trying to send the raw data from my samsumg dvd remote.

This is the up button when i use "IRrecvDump"

Raw (76): -7764 4650 -4450 550 -450 600 -400 600 -400 600 -400 600 -1400 600 -1400 600 -400 600 -450 550 -450 600 -1400 600 -400 600 -1400 600 -1400 600 -400 600 -400 600 -400 600 -4450 600 -400 600 -400 600 -450 550 -450 600 -400 600 -1400 600 -1400 600 -400 600 -400 600 -450 550 -1400 600 -1400 600 -1400 600 -400 600 -450 600 -1400 550 -1400 600 -1400 600 -450 600

My arduino code is:

unsigned int up[76] = {4650,4450,550,450,600,400,600,400,600,400,600,1400,600,1400,600,400,600,450,550,450,600,1400,600,400,600,1400,600,1400,600,400,600,400,600,400,600,4450,600,400,600,400,600,450,550,450,600,400,600,1400,600,1400,600,400,600,400,600,450,550,1400,600,1400,600,1400,600,400,600,450,600,1400,550,1400,600,1400,600,450,600};

and i use "irsend.sendRaw(up,76,38);" to send the data.

Nothing happens with my dvd player....

What am i doing wrong?

Thanks, Samuel!

Anonymous said...

Hi,

Search in comments by "samsung" and you'll find functions to use samsung protocol.

Julez Stone said...

Hi there, I have seen and tested the Samsung protocol and that works fine but some how this is different. I Have a version of Ken's lib that recognise the Samsung protocol, but I have a Samsung blu ray, DVD player. It's the blu ray buttons that come up with the raw code that I posted earlier, and it states that it's unknown and just gives me the raw dumped data...any ideas? Thanks!

Voodenn said...

I just acquired an XBox360 to use as a Media Center Extender with my Microsoft Windows Media Center.

The XBox works with a standard RC6 Media Center Remote.

It works great.

Except: The Volume Up and Down buttons are incapable of changing the volume at the level of the Xbox.
Microsoft wants the user to control volume ONLY at the level of the TV.

I have attempted to make an Arduino soultuin to the problem that will RECEIVE the Volume Up/Down code from mthe RC6, and upon its receipt, "rebroadcast it" AS RCA codes (for my old RCA TV).

Problem:
Although the receive section and the send section of my code work fine SEPARATELY, when I string them together, the program locks up.
Code is attached.

The first press of the remote button gives the desired behavior.
Both the Serial Output, and also the Volume of the TV goes UP.

Subsequent presses do nothing (either to Serial Output or the TV).

Any thoughts on this ?

Thank you.

Bob W.
(code follows)


#include

unsigned int RCAVOLUP[52] =
{
4000 ,4000 ,
550 ,1900 ,550 ,1900 , //11 // F
550 ,1900 ,550 ,1900 , //11
550 ,950 ,550 ,950 , //00 // 2
550 ,1900 ,550 ,950 , //10
550 ,1900 ,550 ,1900 , //11 // F
550 ,1900 ,550 ,1900 , //11
550 ,950 ,550 ,950 , //00 // 0
550 ,950 ,550 ,950 , //00
550 ,1900 ,550 ,1900 , //11 // D
550 ,950 ,550 ,1900 , //01
550 ,950 ,550 ,950 , //00 // 0
550 ,950 ,550 ,950 //00
};

int iReading;

IRsend irsend;


// ** for IR ** //
// Pin 9 VCC
// Pin 10 GND
int RECV_PIN = 11; //11;
IRrecv irrecv(RECV_PIN);
decode_results results;



void setup()
{
/* Set up oins 2-13 as OUTPUT */
for (int i=2; i<=13; i++) pinMode(i, OUTPUT);
for (int i=2; i<=13; i++) digitalWrite(i, LOW);

/* Diagnostic Messages to Serial Monitor */
Serial.begin(9600);
Serial.println("Ready");

/* Demonstrate that Send Codes Work */
irsend.sendRaw(RCAVOLUP,52, 57);
delay(250);
irsend.sendRaw(RCAVOLUP,52, 57);
delay(250);
irsend.sendRaw(RCAVOLUP,52, 57);
delay(250);
irsend.sendRaw(RCAVOLUP,52, 57);
delay(250);
irsend.sendRaw(RCAVOLUP,52, 57);
delay(250);

// ** fSet Up IR Receiver ** //
digitalWrite(9, HIGH); // 9 convenient VCC
digitalWrite(10, LOW); // 10 convenient GND
irrecv.enableIRIn(); // Start the receiver
}


void loop()
{
if (irrecv.decode(&results))
{
/* Get Received Codes and Print to Serial Monitor */
iReading = results.value;
Serial.println(iReading % 0x8000, HEX);

/* If RECEIVED Volume Up coade from RC6 remote, then transmiat RCA Volume Up code */
if ( (iReading % 0x8000 ) == 0x410)
{
irsend.sendRaw(RCAVOLUP,52, 57);
}

/* PROGRAM SEEMS TO LOCK UP HERE !!!!! */

irrecv.resume(); // Receive the next value
}
}

Voodenn said...

First line of my code (in last ost) didn't print right because of angle brackets.

Should be:

#include (gt) IRremote.h (lt)

Voodenn said...

SOLVED!

Putting:
irrecv.enableIRIn();

before: irrecv.resume();

Did the trick.

Now I can control my TV sound with my MCE remote.

Thanks for listening.
And thanks for the great library !

Julez Stone said...

Hi Ken, I've notices a very strange problem with your lib and the strcmp command... if you use the strcmp command more than 9 times all the code locks up and it starts to pulse out radonm infrared data. E.g the following times 9.

if(strcmp(inData, chDown)==0)
{
//send out iron data
}
else if (strcmp(indata,chDown)==0){
//send ir data
}

any ideas? I may be missing something silly.... Thanks!

Julez Stone said...

Hi all, is there anyway to shorten down the raw code? Im having trouble sending more than 9 buttons on my remote. all buttons will record ok, but when i have more than 9 buttons for "Sending" the program locks up. I can "send" 8 buttons with no problem...

e.g
unsigned int back[78]
= {
4600,4500,550,450,550,450,550,450,600,400,600,1400,600,1400,600,450,550,450,550,450,550,1450,550,450,550,1450,550,1450,550,450,600,400,600,450,550,4450,600,400,600,450,550,450,550,450,550,1450,550,450,600,1400,600,400,600,1400,600,450,550,450,550,1450,550,450,550,1450,550,450,550,1450,550,450,550,1450,550,1450,550,450,600};
unsigned int totalexit[78]
= {
4600,4450,600,450,550,450,550,450,550,450,600,1400,600,1400,600,400,600,450,550,450,550,1450,550,450,550,1450,550,1450,550,450,550,450,600,400,600,4450,550,450,600,450,550,450,550,450,550,1450,550,450,550,1450,550,450,550,450,600,450,550,450,550,450,550,450,600,1400,600,400,600,1400,600,1400,600,1400,600,1400,550,1450,550};
unsigned int guide[78]
= {
4650,4450,550,450,600,400,600,400,600,450,550,1400,600,1400,600,450,550,450,600,400,600,1400,600,400,600,1400,600,1400,600,400,600,400,600,450,600,4400,600,450,550,450,600,400,600,400,600,1400,600,1400,600,1400,600,400,600,400,600,450,550,1450,550,450,600,400,600,400,600,400,600,1400,600,1400,600,1400,600,400,600,1400,600};
unsigned int record[78]
= {
4600,4450,600,450,550,450,600,400,600,400,600,1400,600,1400,600,400,600,400,600,450,550,1450,550,450,600,1400,600,1400,550,450,600,400,600,400,600,4450,600,400,600,400,600,450,550,450,600,400,600,1400,600,400,600,400,600,450,550,450,600,1400,600,1400,600,1400,550,450,600,1400,600,1400,550,1450,550,1400,600,450,600,400,600};
unsigned int menu[78]
= {
4650,4450,550,450,600,400,600,400,600,450,550,1450,550,1450,550,450,600,400,600,400,600,1400,600,400,600,1400,600,1400,600,400,600,450,550,450,600,4450,550,450,600,400,600,400,600,400,600,1400,600,1400,600,450,550,1400,600,450,550,450,600,400,600,1400,600,400,600,400,600,1400,600,450,550,1450,550,1450,550,1400,600,450,550};
unsigned int power[78]
= {
4650,4450,550,450,600,400,600,450,550,450,600,1400,600,1400,550,450,600,400,600,400,600,1400,600,400,600,1400,600,1400,600,450,550,450,600,400,600,4450,550,450,600,400,600,400,600,450,550,1450,550,450,600,400,600,400,600,1400,600,400,600,450,550,1450,550,450,600,1400,600,1400,550,1400,600,450,600,1400,550,1450,550,450,600};
unsigned int chup[78]
= {
4600,4450,500,500,600,450,550,450,600,400,600,1400,600,1400,600,400,600,400,600,450,550,1450,550,450,600,1400,550,1450,550,450,600,400,600,400,600,4450,550,450,600,400,600,450,550,450,600,1400,600,400,600,1400,600,400,600,400,600,450,550,1400,600,1400,600,450,550,1450,550,450,600,1400,600,1400,600,1400,550,450,600,400,600};
unsigned int chDWN[78]
= {
4650,4450,550,450,600,400,600,400,600,450,550,1400,600,1400,600,450,550,450,600,400,600,1400,600,400,600,1400,600,1400,600,400,600,400,600,450,550,4450,600,400,600,450,550,450,600,400,600,400,600,1400,600,1400,600,400,600,450,550,450,600,1400,550,1450,550,1450,550,450,600,400,600,1400,600,1400,600,1400,550,450,600,400,600};
unsigned int tools[78]
= {
4650,4450,550,450,550,450,600,450,550,450,550,1450,550,1450,550,450,550,450,550,450,600,1400,600,400,600,1400,600,1400,600,400,600,450,550,450,550,4450,600,450,550,450,550,450,550,450,600,1400,600,400,600,450,550,1450,550,450,550,450,550,450,600,400,600,450,550,1450,550,1400,600,450,550,1450,550,1450,550,1400,600,1400,600};
but as soon as i add another the program no longer works....

Lauszus said...

@Julez Stone
You are most likely running out of RAM. Try to use PROGMEM to save it in the flash instead.
See the following page for more information: http://www.nongnu.org/avr-libc/user-manual/group__avr__pgmspace.html

And here is how it works in practice: https://github.com/TKJElectronics/USB_Host_Shield_2.0/blob/master/PS3BT.cpp#L27
And here is how to read the array: https://github.com/TKJElectronics/USB_Host_Shield_2.0/blob/master/PS3BT.cpp#L252

You just have to implement it in the sending code for it to work properly.

Or even better. Create a fork at github and add the protocol :)

Regards
Lauszus

Migetron said...

Hi guys,

I need some help I using a ATmega 1280 and I have my IRremote.ccp file changed to this:

-----------------------------

#if defined (__AVR_ATmega1280__) || defined(__AVR_ATmega2560__)
pinMode(10, OUTPUT);
digitalWrite(10, LOW); // When not sending PWM, we want it low
#else
pinMode(3, OUTPUT);
digitalWrite(3, LOW); // When not sending PWM, we want it low
#endif

-------------------------------

(without these "-")

I have the ir led conected from pin 9 then 220ohm resistor then to ground. But it still will not send my code of "irsend.sendNEC(0x10EF08F7, 32);"
in the IRsendDemo or even in the other file, any help here would be great guys thanks.

Kind regards,
Migetron

Migetron said...

Sorry guys I typed that wrong it is pin 9 not 10.

Julez Stone said...

@Lauszus,

Thanks for the help. Ive done research and now i have a general understanding of the "PROGMEM" function....But im a bit stumpped on how to write it into the send function.... any further pointers?

Thanks again!

Lauszus said...

@Julez Stone
What I would do is just store the data in a temporary buffer, as I did with my PS3 Bluetooth library: https://github.com/TKJElectronics/USB_Host_Shield_2.0/blob/master/PS3BT.cpp#L251-252

Just create a for-loop in the beginning of your sending routine and then store the data in a array and then pass that on to the library.

Regards
Lauszus

Julez Stone said...

@Lauszus

This is what I have so far but no luck.

Sorry, new to this.

Do i need to edit the Lib send raw function then?

#include

#include

IRsend irsend;

PROGMEM prog_uint16_t chUP[100]
= {
4650,4450,550,450,600,400,600,400,600,450,550,1400,600,1400,600,450,550,450,600,400,600,1400,600,400,600,1400,600,1400,600,400,600,400,600,450,550,4450,600,400,600,450,550,450,600,400,600,400,600,1400,600,1400,600,400,600,450,550,450,600,1400,550,1450,550,1450,550,450,600,400,600,1400,600,1400,600,1400,550,450,600,400,600};

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

void loop() {

unsigned int chupInt;
chupInt = pgm_read_word_near(chUP);

irsend.sendRaw(chupInt, 100, 12); // Channel down
delay(2000);
irsend.sendRaw(chupInt, 100, 12); // Channel down
delay(2000);

}

Lauszus said...

@Julez Stone
You don't need to edit the library at all.
You are almost there. This is how I would do it:

#include

IRsend irsend;

prog_uint16_t chUP[100] PROGMEM = {
4650,4450,550,450,600,400,600,400,600,450,550,1400,600,1400,600,450,550,450,600,400,600,1400,600,400,600,1400,600,1400,600,400,600,400,600,450,550,4450,600,400,600,450,550,450,600,400,600,400,600,1400,600,1400,600,400,600,450,550,450,600,1400,550,1450,550,1450,550,450,600,400,600,1400,600,1400,600,1400,550,450,600,400,600
};

unsigned int chupInt[100];

void setup() {
}

void loop() {
for (uint8_t i = 0; i < 100; i++)
chupInt[i] = pgm_read_word_near(&chUP[i]);

irsend.sendRaw(chupInt, 100, 38);
delay(2000);
irsend.sendRaw(chupInt, 100, 38);
delay(2000);
}

I also changed the modulation frequency to 38kHz, as I thought you must have made a typo.

Regards
Lauszus

amit kumar said...

hello , i have successfully use my tv remote to control the home appliance using atmega 168. but i want to do it with atmega8 , but there is a error in compile . can u tell me what should i do in lib so that i can upload the program in atmega8.
thanks

Lauszus said...

@amit kumar
I think it will work if you use timer1.
Uncomment the following line: https://github.com/shirriff/Arduino-IRremote/blob/master/IRremoteInt.h#L62.

Remember also to comment out the next line (Line 63).

Regards
Lauszus

Anonymous said...

Here is a first cut at porting library to 32-bit maple. I assume the Arduino Due will have a slightly different API for the timers.

https://github.com/manitou48/maple-IRremote

Unknown said...

Hi Ken! Thanks so much for this GREAT library!

I have gotten your "Receive" example working with a universal remote I had laying around, but it only gives me hex codes for the volume and channel button presses. The power button and individual numbers do nothing (only "0" is printed out).

Ultimately, I want to record (just make note of) the hex codes for an infrared indoor helicopter remote control, but I have the same problem there--all "0"s are printed to the serial monitor.

I know that my IR receiver is getting data from both remotes on all buttons because I have a LED hooked up to the out pin that flashes brightly whenever I press a button on either of the controls.

Any thoughts?

THANKS AGAIN!

Daryl Maunder said...

Thanks for the great work Ken,

I have a couple of Mitsubishi air conditioners, and have added an additional protocol for it, it seemed to be the fairly similar to NEC except 36 bits, and with all the timings different.

#define MITSUBISHI_HDR_MARK 3450
#define MITSUBISHI_HDR_SPACE 1650
#define MITSUBISHI_BIT_MARK 400
#define MITSUBISHI_ONE_SPACE 1250
#define MITSUBISHI_ZERO_SPACE 450
#define MITSUBISHI_RPT_SPACE 1700
#define MITSUBISHI_RPT_LENGTH 60000

I just replicated everything for NEC into an identical pair of routines for Mitsubishi. I now get a successful Mitsubishi decode, but they are always the exactly the same no matter what key is pressed.

4D364800
Decoded Mitsubishi: 4D364800 (36 bits)
Raw (76): 21320 3400 -1700 400 -1250 450 -1250 400 -450 400 -400 450 -400 400 -1300 400 -450 400 -400 400 -1300 400 -1250 400 -450 400 -1300 400 -400 450 -400 400 -1300 400 -1250 400 -450 400 -1250 450 -1250 400 -450 400 -450 400 -1250 400 -450 400 -450 400 -1250 400 -450 400 -450 400 -450 400 -400 400 -450 400 -450 400 -450 400 -400 400 -450 400 -450 400 -450 400

Any ideas?

Konstantin Metodiev said...

Hi! I have a code for a DC motor control as well as a problem with the code:
/*
* http://arcfn.com
*/

#include

int leftPins[] = {5,7,4}; //Pin 5 enables L293D, pins 7 and 4 are intended for PWM, i.e. motor direction
int RECV_PIN = 2;//This is the INT0 Pin of the ATMega8
IRrecv irrecv(RECV_PIN);
decode_results results;
int wait = 5000;

void setup() {
//Serial.begin(9600);
for (int i = 0; i < 3; i++) pinMode(leftPins[i], OUTPUT);// pinMode(leftPins[0], INPUT);
pinMode(leftPins[0], OUTPUT);
irrecv.enableIRIn();//Start the receiver
}//setup

void loop() {
if (irrecv.decode(&results)) {
//Serial.println(results.value, HEX);
//Serial.println(results.value, DEC);

switch (results.value) {
//Now pay attention to analogWrite(leftPins[0], 0); on 3th and 4th rows.
//If nothing stopped the DC motor it would rotate endlessly
//and I would not be able to switch to another case.
//Stated simply, the code gets blocked.
//Asked simply, why? The method irrecv.resume(); supports interrupt, doesn't it?
case 0x1FE609F: digitalWrite(leftPins[1], LOW); digitalWrite(leftPins[2], HIGH); break;//Vol- on my remote
case 0x1FEA05F: digitalWrite(leftPins[1], HIGH); digitalWrite(leftPins[2], LOW); break;//Vol+ on my remote
case 0x1FE708F: analogWrite(leftPins[0], 122); delay(wait); analogWrite(leftPins[0], 0); break;//Button 6 on my remote
case 0x1FE9867: analogWrite(leftPins[0], 255); delay(wait); analogWrite(leftPins[0], 0); break;//Button 9 on my remote
default: break;
}//switch

irrecv.resume(); //Receive the next value

}//if irrecv.decode

}//loop

The code blocks as it is explained in the comment just below the "switch". What does go wrong? Should I didn't stop the motor by typing code, I would not be able to switch between different cases by means of the remote control.
Any suggestions would be appreciated.
10x in advance!

Konstantin Metodiev said...

You may see a screenshot here:
http://www.space.bas.bg/acsu/pics/problem.PNG
Having turned the motor on, it keeps on rotating thus preventing me from switching to another mode.

Anonymous said...

it is possible to send RAW data from web ? if its how ?

rubot said...

IRrecvDemo works fine on my Arduino Uno but i can't get it to work with my Arduino Leonardo. Michael Rogers said...
"The IRremote library on github (b25accf as of moment of writing) worked for me on an Arduino Leonardo. I just had to:
#define TIMER_PWM_PIN 10"


what does that mean? how would that help IRrecvDemo?

C. Weeks said...

You have to go into the supporting IR library and edit that line to the proper pin for your board. I think the file you need to edit is "IRremote.h" but I may be wrong.

Daniel Vilela said...

Hi! Nice library! I got the codes of almost all of my remotes! But there is one that the ouput is always 0! My air conditioner controller! I can't figure out how to make it work! Have you experienced that? Thanks!

Anonymous said...

thank's for this library! now i can control, whit a dvd remote, my giovamazingBOT
http://www.youtube.com/watch?v=NSSR-c6tUuU

Daryl said...

Can somebody explain how to use SendRaw.

I want to send the following 97 bit binary code to an Kelvinator Aircon

01100100100110101011111101000000010110011010011111011001001001101010111111010000000101100110100110000000000000000000000000000000000000000000000000

Daryl said...

Hey Brewin' Brian,

I am also trying to control a Mitsubishi Aircon. I had also got the code working to detect the 292 marks (actually 2 repeats of 146) but haven't got it working to send yet. Any chance of some code sample for sending?

Seems like Aircons are what everyone is struggling with.

Ayush Bhatnagar said...

how can i use ir receiver to to receive it in a hierarchical manner i.e.for instance we have 2 buttons,if 1st button is pressed once,then arduino should receive further signals....and if 2nd button is pressed,it shouldn't receive any signal....plz help:)

Unknown said...

Hi Ken,

I've got a very simple code, but it seems to crash after a while and I can't work out why.


#include

IRsend irsend;

void setup()
{

}

void loop() {
irsend.sendRC6(584062515, 32);
}


That's all the code is.

birincisuvari said...

I have been searching this for a long time.Thanks a lot.You are my hero

Anonymous said...

Hi I'm having trouble with the sending code. I'm able to receive just fine but when I send I get nothing. The IR LED doesn't even light up when I look through the camera.

I've troubleshooted all my basic possible issues (the LED works fine/is in the right way, the pin works with other codes, There is no voltage coming out of pin 3 when I use this IR code only) so I don't know what the issue could be even if there wasn't enough voltage coming out of pin 3 to power the LED, the multimeter should pick it up no matter how small.

Not even the sample code works so I don't know what the issue is if anyone could help me on this issue that would be great. Thanks

- Ozzie

Larry Holthouser said...

I have my Dish DVR 625 working using the Ken's library and irsend.

I made the following changes:

// IRremoteInt.h
#define DISH_HDR_MARK 525
#define DISH_HDR_SPACE 6045
#define DISH_BIT_MARK 440
#define DISH_ONE_SPACE 1645
#define DISH_ZERO_SPACE 2780
#define DISH_RPT_SPACE 6115
#define DISH_TOP_BIT 0x8000

// IRremote.cpp
void IRsend::sendDISH(unsigned long data, int nbits)
{
enableIROut(56);
mark(DISH_HDR_MARK);
space(DISH_HDR_SPACE);
for (int i = 0; i < nbits; i++) {
if (data & DISH_TOP_BIT ) {
mark(DISH_BIT_MARK);
space(DISH_ONE_SPACE);
}
else {
mark(DISH_BIT_MARK);
space(DISH_ZERO_SPACE);
}
data <<= 1;
}
mark(DISH_BIT_MARK);
space(DISH_RPT_SPACE);
}

I am also using the codes from http://lirc.sourceforge.net/remotes/dishnet/Dish_Network (Not my own work here)

I am sending the codes via URL and using these decimal codes:

Function Dish Binary Hex Decimal
info 0 0000-0000-0000-0000 0000 0
power_on 1 0000-0100-0000-0000 0400 1024
power 2 0000-1000-0000-0000 0800 2048
play 3 0000-1100-0000-0000 0C00 3072
1 4 0001-0000-0000-0000 1000 4096
2 5 0001-0100-0000-0000 1400 5120
3 6 0001-1000-0000-0000 1800 6144
page_down 7 0001-1100-0000-0000 1C00 7168
4 8 0010-0000-0000-0000 2000 8192
5 9 0010-0100-0000-0000 2400 9216
6 10 0010-1000-0000-0000 2800 10240
menu 11 0010-1100-0000-0000 2C00 11264
7 12 0011-0000-0000-0000 3000 12288
8 13 0011-0100-0000-0000 3400 13312
9 14 0011-1000-0000-0000 3800 14336
page_up 15 0011-1100-0000-0000 3C00 15360
select 16 0100-0000-0000-0000 4000 16384
0 17 0100-0100-0000-0000 4400 17408
cancel 18 0100-1000-0000-0000 4800 18432
guide 20 0101-0000-0000-0000 5000 20480
view 22 0101-1000-0000-0000 5800 22528
tv_vcr 23 0101-1100-0000-0000 5C00 23552
right 24 0110-0000-0000-0000 6000 24576
up 26 0110-1000-0000-0000 6800 26624
recall 27 0110-1100-0000-0000 6C00 27648
left 28 0111-0000-0000-0000 7000 28672
down 30 0111-1000-0000-0000 7800 30720
record 31 0111-1100-0000-0000 7C00 31744
pause 32 1000-0000-0000-0000 8000 32768
stop 33 1000-0100-0000-0000 8400 33792
sys_info 36 1001-0000-0000-0000 9000 36864
asterisk 37 1001-0100-0000-0000 9400 37888
pound 38 1001-1000-0000-0000 9800 38912
power_off 39 1001-1100-0000-0000 9C00 39936
sat 41 1010-0100-0000-0000 A400 41984
back 49 1100-0100-0000-0000 C400 50176
fwd 50 1100-1000-0000-0000 C800 51200
dish 52 1101-0000-0000-0000 D000 53248
skip_back 54 1101-1000-0000-0000 D800 55296
skip_fwd 55 1101-1100-0000-0000 DC00 56320
dish_home2 56 1110-0000-0000-0000 E000 57344
dvr 57 1110-0100-0000-0000 E400 58368

K. said...

I'd like to update the library to support Leonardo, but since I don't have one, I'll need the help of my readers.

I think line 363 in IRremoteInt.h (the line that gets the compile error) needs to be changed from

#error "Please add OC4A pin number here

to

#define TIMER_PWM_PIN 13

I think pin 13 is the OC4A PWM output, but other people have said pin 6 or 10.

So if anyone knows for sure, let me know and I'll update the library.

Thanks,
Ken

Shine said...

I was able to control my Samsung Air conditioner. I posted all dumped IR codes here:

https://docs.google.com/spreadsheet/ccc?key=0Aupzmp8AqC8JdGtNOXhUc0R0WC1hbVdRa0p3aDVxdFE#gid=0


I hope this'll help someone, the codes works with IRsend functions.

I really can't figure out how to compute checksum (2 byte out of 7). If anyone figured out how to compute Samsung IR checksum please contact me at shine (@) angelic.it

Angel Manuel Garcia Martin said...

Hi !!!
I've the same problem , I have an exit like yours.

My IR received is this http://www.flickr.com/photos/[email protected]/7742295102/in/photostream

I've disengaged the received module to use with arduino.
In the IR's description says Encoding Type: Fixed code but I cant obtain any code with the Ken library.

I hope you can help me to obtain the codes.

Thank you very much

Edencircle said...

May I know how can I invert my IR output signal using IRsend, i.e. 0->1 and vice versa.

I'm making a infrared intercept module on top of my IR repeater so that only the IR codes of few specific but not all devices are feeded from my bed room to sitting room.

Pls read its configuration:
http://myweb.polyu.edu.hk/~itanthea/harry/irmodule.pdf


I've successfully built it. The module was able to redirect IR codes and transmit thru a IR LED. We directly feed the IR codes to another IR receiver circuit instead of thru IR LED, the module become not work. I learnt that I must invert the output level. I've tried negate the send codes before passing to IRsend but it does not work. I finally add an external negation circuit using a NPN transitor to invert the output. The circuit become works but not reliable. The successful rate dropped to abt 30%. I think it will be much better if I invert the ouptut within Ken's library. Please kindly help

Lauszus said...

@Ken

I just added support for the Arduino Leonardo. See github: https://github.com/shirriff/Arduino-IRremote/pull/13

Regards
Lauszus

Rev. F. said...

Is there any way to use two IR LEDs to control two devices? I want to turn off a device then turn on an another, and daily swap them. We do it manually at the moment :D

C. Weeks said...

Just send one command and then the other. No need for 2 LEDs.

Edencircle said...

I don't familar with AVR timer. Please teach me how to invert all the IR output from HIGH to LOW and from LOW to HIGH?

devlware said...

Hi,

I have a small board with ATMega16U4 running 16Mhz and I'm trying to use IRRemote without success.
I'm compiling the program in Atmel Studio 6 and using the Arduino Library. Also I have the IR sensor (38Khz) attached to pin PD5.

I'm running the recvdump sketch with debug messages enabled and here is the logs:

BAAC716C
Could not decode message
Raw (72): 9344 1150 -550 100 -50 50 -200 100 -200 50 -100 50 -100 50 -100 50 -50 100 -200 50 -250 50 -200 100 -50 50 -200 100 -50 100 -200 50 -250 50 -50 100 -200 50 -100 50 -200 100 -50 100 -200 50 -100 50 -50 100 -50 100 -50 50 -250 50 -50 100 -200 50 -100 50 -200 100 -200 50 -250 50 -5000 1100 -300 50
DE14404C
Could not decode message
Raw (72): -27698 1150 -550 50 -100 50 -200 100 -200 50 -100 50 -50 100 -50 100 -50 50 -250 50 -200 100 -200 50 -100 50 -200 100 -50 50 -250 50 -200 100 -50 50 -250 50 -50 100 -200 50 -100 50 -200 100 -50 100 -50 100 -50 50 -100 50 -200 100 -50 100 -200 50 -50 100 -200 100 -200 50 -200 100 -4950 1150 -250 100
3F3E464F
Could not decode message
Raw (72): 19416 1100 -600 50 -50 100 -200 100 -200 50 -50 100 -50 100 -50 100 -50 50 -250 50 -200 50 -250 50 -100 50 -200 100 -50 50 -250 50 -200 100 -50 50 -100 50 -200 100 -50 100 -50 50 -250 50 -50 100 -50 100 -50 50 -250 50 -50 100 -200 50 -250 50 -50 100 -200 50 -250 50 -200 100 -4950 1150 -250 100
248C15D9
Could not decode message
Raw (72): 8388 1100 -550 100 -50 100 -200 50 -200 100 -50 100 -50 50 -100 50 -100 50 -200 100 -200 50 -200 100 -50 100 -200 50 -100 50 -200 100 -200 50 -100 50 -50 100 -200 50 -100 50 -100 50 -200 100 -50 50 -100 50 -100 50 -200 100 -50 100 -200 50 -200 100 -50 100 -200 50 -200 100 -200 50 -5000 1100 -300 50

Every time I press a button in the remote control (which generates NEC codes) the firmware return a different 32 bit code. I notice that the first 9000 NEC_HDR_MARK and 4500 NEC_HDR_SPACE are not been shown. I don't know how these "pulses" are been lost by the program. Also the number for the SPACES and MARKS are very far from the normal 560, 1600, 560.

I already checked the IRremoteInt.h trying to find something unusual and related with the timers but I couldn't find.

I really thought that using ATMega16U4 instead of ATMega32U4 (which runs smoothly) should be ok as they have the same pinout, just less memory in the 16U4.

Thanks in advance for any help, Diego

Alex said...

Hi Ken Shirriff
I' m really exciting about your library.
But I have a problem sending the values from my remote through the send function.
I use your library to receive code from remote of TATUNG air conditioner is "8A9A627D" and "FD9681B5" with ON/OFF button. Then I try to send this code to control this air conditioner form IR sensor. I see the plusing but nothing happen. I don't know what is problem here. I try by send function with irsendNEC.

Anonymous said...

Hi Ken
I'm really excited about your library. I try with air conditioner of TATUNG. when I use Receiver function I receive two code with ON/OFF function. 7D5DF607 and A61D6CF
I try to send this code to control but nothing happen. I use irsend.sendNEC(0x7D5DF607) funtion. You can support me IR protocol of TATUNG air conditioner.

Anonymous said...

Hi Ken
I'm really excited about your library. I try with air conditioner of TATUNG. when I use Receiver function I receive two code with ON/OFF function. 7D5DF607 and A61D6CF
I try to send this code to control but nothing happen. I use irsend.sendNEC(0x7D5DF607) funtion. You can support me IR protocol of TATUNG air conditioner.

Unknown said...

Hi Ken! great job! great library!
Do you have an example of code related to control of two or more devices? How can I extend the code?I'm a begginer in the arduino. My idea is, using the arduino, to control all devices ( TV, radio, DVD). Please, help-me.

Unknown said...

Hi Ken! great job! great library!
Do you have an example of code related to control of two or more devices? How can I extend the code?I'm a begginer in the arduino. My idea is, using the arduino, to control all devices ( TV, radio, DVD). Please, help-me.

C. Weeks said...

The code doesn't care if you are controlling 2, 3, or even a dozen different devices. It's all just codes. You can store the codes for your tv, then store the codes for your dvd player, and your home theater receiver, then just play them back at will. You can even play them back sequentially, say 1 button press sends the TV ON, DVD Player ON, and Receiver ON back to back to back.

Was that any help?

Scott said...

Hey guys.
I have added a Samsung protocol to the library and everything is working great. I am now trying to control my ac unit but I am having some trouble. I got all the timings of the remote from the dump and I have doubled checked them with an oscilloscope.
The dump is:
A4B2955B
Unknown encoding: A4B2955B (32 bits)
Raw (44): 15050 4450 -4350 650 -1600 550 -500 650 -500 600 -500 600 -500 600 -500 600 -500 650 -500 550 -550 600 -1600 600 -500 600 -500 600 -1650 600 -1600 600 -1600 600 -1600 650 -1600 600 -1600 600 -500 650 -500 550

Which means it is sending: 1000 0000 0100 1111 1100(804FC) and is only 20 bits. Which is all well and good but the problem I am having it that it repeats x3 with a 18420us pause between each. So I have added the following parameters to the IRremoteint file:
AC_HDR_MARK 4450
AC_HDR_SPACE 4350
AC_BIT_MARK 600
AC_ONE_SPACE 1600
AC_ZERO_SPACE 500
AC_RPT_SPACE 18420

I have been able to turn on and off the AC unit by sending raw codes in triplicate but I don't have a lot of memory available and cant afford to define 9 rawcodes in my program.
I know that the Sony protocol sends in triplicate so I tried to modify the the irsend::sendSony function but it did not work. I am new to C/C++ and I don't really understand how/why the bits are being shifted around.(i.e. data = data << (32 - nbits);) So a sony code is 12 bits. 32-12=20. So the data is being shifted to the left 20bits?? Something to do with MSB, and LSB?

I am at a loss of how to write a function to send 20 bits, 3 times, with an exact spacing? Any help would be greatly appreciated!

kiranvarma-npeducations said...

Hi i need the remote.h header file.
please upload it.

C. Weeks said...

At the very top of the page, the big yellow block that reads "Note for Arduino 1.0" is the github link for all of the updated files.

Anonymous said...

Hi Ken,

I get a compile error when I run the IRrelay or other sketches. Only one that works so far is the IR receive dump. I do see the codes and raw data.

I'm using the Arduino 1.0.1 IDE from aruduino site.

Now I have the codes, do I have to paste it somewhere? I notice something called keywords. Is this where I paste in order for sketch to compare keycodes?

Thanks

C:\arduino-1.0.1-windows\arduino-1.0.1\libraries\IRremote\IRremote.cpp:943: warning: this decimal constant is unsigned only in ISO C90
In file included from C:\arduino-1.0.1-windows\arduino-1.0.1\libraries\IRremote\IRremote.cpp:22:
C:\arduino-1.0.1-windows\arduino-1.0.1\libraries\IRremote\/IRremoteInt.h:15: error: expected unqualified-id before '.' token
C:\arduino-1.0.1-windows\arduino-1.0.1\libraries\IRremote\/IRremoteInt.h: In function 'int MATCH_MARK(int, int)':
C:\arduino-1.0.1-windows\arduino-1.0.1\libraries\IRremote\/IRremoteInt.h:178: error: 'MATCH' was not declared in this scope
C:\arduino-1.0.1-windows\arduino-1.0.1\libraries\IRremote\/IRremoteInt.h: In function 'int MATCH_SPACE(int, int)':
C:\arduino-1.0.1-windows\arduino-1.0.1\libraries\IRremote\/IRremoteInt.h:179: error: 'MATCH' was not declared in this scope
C:\arduino-1.0.1-windows\arduino-1.0.1\libraries\IRremote\IRremote.cpp: In member function 'int IRrecv::getRClevel(decode_results*, int*, int*, int)':
C:\arduino-1.0.1-windows\arduino-1.0.1\libraries\IRremote\IRremote.cpp:702: error: 'MATCH' was not declared in this scope

Anonymous said...

Hi,

The IR Decoding is working now.

My question is for the Apple Remote NEC protocol. Keeping the button pressed down gives you all F's.

How do you make a sketch so that is will continue to read the F's and send pin high until released?

In my instance, I want to keep the remote volume + pressed and it will continue to increase the motor volume until I release.

This is basic one so far that will connect to the L298 motor driver.

Thanks

#include

int RECV_PIN = 11;
IRrecv irrecv(RECV_PIN);
decode_results results;
int led7 = 7;
int led8 = 8;

void setup()
{
pinMode(led7, OUTPUT);
pinMode(led8, OUTPUT);

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

digitalWrite(led7, LOW);
digitalWrite(led8, LOW);

}

void loop() {
if (irrecv.decode(&results)) {
switch (results.value) {

case 2011287691: //UP
digitalWrite(led7, LOW);
delay(500);
digitalWrite(led7, HIGH);
break;

case 2011279499:
digitalWrite(led8, LOW);
delay(500);
digitalWrite(led8, HIGH);
break;


}
digitalWrite(led7, HIGH);
digitalWrite(led8, HIGH);
irrecv.resume(); // Receive the next value
}
}

Teo said...

Hi Ken, thanks for the great library!!!! But I have some problem with the aircon. May i know got any solution? Thanks!

Anonymous said...

For those who have experienced the "does not name..." error and others, I had the same issue and it was very simple solution. In my IRremote foler, I had another subfolder with the full filename "shirrif...". Once I moved my "arduino-1.0.1-windows" folder to the Program Files folder and made sure that the IRremote.cpp and IRremoteInt.h files were in the following location, everything compiled fine.

C:\Program Files\arduino-1.0.1-windows\arduino-1.0.1\libraries\IRremote

Teo said...

Hi, I am the beginner of arduino, I had success for recording and send the infrared signal to the "old type" air conditional but I have some problem with the "new type" panasonic air conditional. Can anyone help me? Thanks.

Jason said...

I am trying to start from a "teeny" (pre made arduino board) to build a remote for my TV. Right now I can get it to work but I have to send all the commands one at a time through LIRC. I am having some trouble making the transition from the GUI interface of LIRC to actual code base that I can have on my computer to control the TV. Do you have advice on how to start the transition?

Alessandro said...

Hello all.
Have any of you ever used the library to control an air conditioner???
I am using the examples of Ken Shirriff (IRrecvDemo.ino or IRrecvDump.ino) I get a 16-bit JVC code (the original code for LG is 24-bit or 32-bit.) These are the first 16 bits of the command.

CODE LG, see this topic --> http://arduino.cc/forum/index.php/topic,81997.msg642393.html#msg642393

Who can help me???

thank you very much :-)
(sorry for my bad english)

Alessandro (Italy)

Luzemário said...

Hi Ken,

Latest arduino-1.x version has become slightly big for a ATMEGA8. Can you send me some guidelines for commenting out code to make a 'light' version? I want to receive only my own remote...

Glenn Welker said...

We have had great success with your library but are struggling with a Sanyo air conditioning unit.

Doing a dump gives us a 48bit protocol. We have added a function to push the data but we still cannot get it to work.

Does anyone have a suggestion?

Diego said...

Hey ken,

I am using a Pro Micro - 3.3V/8MHz arduino board (https://www.sparkfun.com/products/10999). The library didnt work out-of-the box with this board.

I would like to know what possibly I should change in order to make it work.

Thanks,

Diego said...

Sorry, adding more info to my previous post.

What I want to do is to use the library in that board to send IR signals.

When I manually code the board to do that, it works. But when I use the library, it doesnt.

Thanks.

Anonymous said...

Hello, I have used the IRremote Library to dump the code of a certain button on my remote control and it worked fine. I move away a little bit and I pressed the same button and it gave a totally different code for the button, any suggestions for that problem

atog said...

Hey, thank you very much for publishing your library. Seems very good and I look forward to test it soon.
However, I'd like to know if the library's use of timer2 or duration of ISRs might conflict with SoftwareSerial library, which I'm currently using.
After googling for a while and reviewing the code of SoftwareSerial library I haven't been able to draw a final conclusion on the matter and would very much appreciate any pointer given!
Thanks in advance for any help!
I do realize i will not be able to use PWM on certain pins and don't mind

Sicness CTOLbHuK said...

I have a problem. Standart function "tone" doesn't work with IR. Compiller sayd:
core.a(Tone.cpp.o): In function tone(unsigned char, unsigned int, unsigned long)':
/home/sicness/arduino-1.0.1/hardware/arduino/cores/arduino/Tone.cpp:230: multiple definition of__vector_7'
IRremote/IRremote.cpp.o:/home/sicness/arduino-1.0.1/libraries/IRremote/IRremote.cpp:70: first defined here

Need help! :)

Sicness CTOLbHuK said...

I have a problem. Standart function "tone" doesn't work. Compiller sayd:
core.a(Tone.cpp.o): In function tone(unsigned char, unsigned int, unsigned long)':
/home/sicness/arduino-1.0.1/hardware/arduino/cores/arduino/Tone.cpp:230: multiple definition of__vector_7'
IRremote/IRremote.cpp.o:/home/sicness/arduino-1.0.1/libraries/IRremote/IRremote.cpp:70: first defined here

Need help! :)

TunaSandwich said...

Has anybody used this with the adafruit motorshield? I find that the library works great (and the motorshield works great on it's own too).

But when I put the two together I loose motors 1 and 2. And if I try and run motor 1 at all, then nothing works.

Anybody come across this yet?

Anonymous said...

Hello Everyone,

Firstly, what a highly knowledgeable bunch of folks you all are and many thanks to Mr. Shirriff.

I wonder if you could assist with a problem I am having?

I have programmed everything up and it all works fine, but two of my remotes clash (when my little Python program sends the code for TV volume down it also tells the DVD to jump to another chapter).
Is it possible to have two IR transmitters connected to the Arduino and for the output to be toggled between them (either controlled via Python or the .ino code)?
(I could then run an IR LED to the TV and the other to the DVD, making sure to cover each LED so no leakage takes place).

All assistance greatly appreciated.

What a fantastic community you make.

p tup said...

hello, I was wondering if you could tell me why IRremoteInt.h does not work when I try to compile it i keep getting the following message when i try to compile


IRremote\IRremote.cpp.o: In function `MATCH(int, int)':
/IRremoteInt.h:176: multiple definition of `MATCH(int, int)'
sketch_oct27b.cpp.o:C:\Users\P-tup\Desktop\arduino-1.0.1\libraries\IRremote/IRremoteInt.h:176: first defined here
IRremote\IRremote.cpp.o: In function `MATCH_MARK(int, int)':
/IRremoteInt.h:177: multiple definition of `MATCH_MARK(int, int)'
sketch_oct27b.cpp.o:C:\Users\P-tup\Desktop\arduino-1.0.1\libraries\IRremote/IRremoteInt.h:177: first defined here
IRremote\IRremote.cpp.o: In function `MATCH_SPACE(int, int)':
/IRremoteInt.h:178: multiple definition of `MATCH_SPACE(int, int)'
sketch_oct27b.cpp.o:C:\Users\P-tup\Desktop\arduino-1.0.1\libraries\IRremote/IRremoteInt.h:178: first defined here

Pauls72 said...

I'm having a problem with the library and can't figure out what it is.

If I write a short sketch or use one of the demo ones it works file. When I just add the library to my existing sketch that I want to add the infrared remote too, the display goes nuts, I get garbage on the LCD display or lost data on the screen, some times the Arduino reboots, some times it hangs. I have no idea where the conflict is.

Anonymous said...

Hello,

library works great. First i manage to control my TV from LG (NEC Protocol) with the Arduino and after that i managed my Hifi from Sony.

The plan is to control them via Android Smartphone.

Now i want to control both Devices and so i need 2 IR Sender but i only have Pin3 (arduino Uno).
Is there a possibility to control two IR Senders with one Arduino?

C. Weeks said...

There have been a couple comments on this situation. Short answer: you only need one sender for any number of codes. The transmitter doesn't care what type of code is sent to it, as it's just blinking to 1's and 0's.

Anonymous said...

yes thats right, but when you want to place the sender correct, it could be that you need 2 senders.

Gregy said...

When I compile my program (the one used in the tutorial about receiving signals) I get an error message: "fatal error: avr/interrupt.h: No such file or directory"

What can I do about this?

P.S.: I'm running on the new IDE 1.5.1 r2.

Dettolo said...

Tips for Arduino Mega 2560:
Outupt PWM pin is PIN 9 and not PIN3.

Fanta said...

@Gregy

Download the additional files from:
https://github.com/shirriff/Arduino-IRremote

And make sure you add them to your Arduino examples folder.
http://www.arduino.cc/en/Hacking/Libraries

Larry LeBron said...

Thanks so much for creating this library! I see that timer choice is now supported in the library. If I include the library twice, with different timers selected, could I support two simultaneous IR receivers getting different messages? Thanks!

Gregy said...

@fanta

Thanks for the help :) , but it's still giving me the same error message :( .

I downloaded the file's again from the link you gave me.
I've putted the files in the examples folder, like you told me, and then it said that it couldn't find IRremote.h .

In the second link you gave me, stood that I needed to put the upoaded folder into /documents/arduino/library/"IRremote".
So I did that and again it gives me the same error message "error: avr/interrupt.h: No such file or directory"

I guess I'm doing something stupid wrong, because I can't find anyone who has the same problem as I do.

Please help me
Thanks already

Gregy said...

I commented earlier about my IDE giving me error messages "could not find file or directory", it couldn't find interrupt.h .
I've also told you I'm running on 1.5.1r2 and that I want to program it on a arduino DUE.

I also e-mailed arduino-support about my problem and they said that the problem was that this library was made for AVR arduino's and not for ARM arduino boards like the DUE.

So my question is simple now: How do I make this library compatible with my ARM board (Arduino DUE)?

I'm not a professional programmer, I'm just a hobbyist, so I would really appreciate it if one of you computer geniuses ;) would wanna help me with making a compatible library.

Thanks already
Regards
Grégoire Coppens

Troy Robert Nachtigall said...

Hi Ken, Thanks a million for your blog.

Does anyone have the NEC codes for the apple remote?

They are detailed on the wikipedia page http://en.wikipedia.org/wiki/Apple_Remote#Technical_details

when I try sending
irsend.sendNEC(0xEE, 32); // checkbit 1
irsend.sendNEC(0x87, 32); // checkbit 2
irsend.sendNEC(0x0d, 32); // first half of volume up
irsend.sendNEC(0x0c, 32); // second half of volume up
I get nothing on the mac, but I can decode on my receiver arduino....

Ben said...

Fantastic work Ken! I was wondering if there is a way to hook 2 or more IR receivers up using the library. If it is possible how would you do that (in the code not hardware)? Thanks

Andy said...

Hey there!
Have some trouble while compiling:

core.a(Tone.cpp.o): In function `__vector_7':
C:\Users\Master\Documents\arduino-1.0-windows\arduino-1.0\hardware\arduino\cores\arduino/Tone.cpp:523: multiple definition of `__vector_7'
IRremote\IRremote.cpp.o:C:\Users\Master\Documents\arduino-1.0-windows\arduino-1.0\libraries\IRremote/IRremote.cpp:311: first defined here

Can anyone help me?

Максим Рубченко said...

In first I want to thanks Ken Shirriff for perfect library.
I try to control AV Reciver Marantz SR 5003 and have some problem, i get a document where describe all ir control codes, there are two type codes in the document what they call RC5 and RC5-Ex. With RC5 there is no problem format in the document:
System: 16
Command: 12
Translate to RC5 as 0xC0C and send with library irsend.sendRC5(0xC0C,12); and it wark good.
But the second type of code have strange format:
System: 16
Command: 12
Extension: 01
Can somebody help me to understand how can i send code with Extension? Or what format of RC5-Ex code?

Sean OBryan said...

Ken - Your library, examples, and explanations are great! Thanks.

Michael Flaga said...

Has there been any thought or effort in using the Timer Input Capture interrupts. One gets more precision and uses less real time, not polling non-changes.
I just came across billroy's InputCapture.ino and fixed it on my fork https://gist.github.com/4404996
Seems like a good fit to merge adding ICT support. It would though be constrained to particular pins. but is a good trade off.

Temoor Anwar said...

Hi Ken,
Thanks for the IRremote codes!. Saving lifes here. Im trying to use a remote to scroll up and down on my pc while I exercise but I dont want to keep pressing it. It just serials out FFFFFFFF until I hit another button. Must be the NEC coding thing you were talking about. My question is how do I fix this with coding. Is there a way to see what the "last" code if the serial sees a bunch of FFFFFF and differential from the up/down presses? Here is my code:

#include
int RECV_PIN = A2;
IRrecv irrecv(RECV_PIN);
decode_results results;
int count = 0;
void setup()
{
Serial.begin(9600);
irrecv.enableIRIn(); // Start the receiver
}
void loop() {
if (irrecv.decode(&results)) {
Serial.println(results.value,HEX);
Serial.println(count);
if (results.value == 1086263535) { ////UP ARROW
Mouse.scroll(2);
count++;
irrecv.resume(); // Receive the next value
}
else if (results.value == 1086259455) { ////DOWN ARROW
Mouse.scroll(-2);
irrecv.resume();
count++;
}
else if (results.value == 1086320655) { ////1
Keyboard.print(0);
irrecv.resume();
}
else if (results.value == 1086264045) { ////2
Keyboard.print(1);
irrecv.resume();
}
else if (results.value == 1086296175) { ////3
Keyboard.print(2);
irrecv.resume();
}
// Receive the next value
else {irrecv.resume();}
}
}

derrij said...

it is possible to connect second IR LED.for control two TVs situated in different places?

Anonymous said...

hey,
thanks for the post.
I use infrared to control RGB LED lamps of 220 and it works well sher.
it is also possible to connect several Ir transmitter to an arduino?
or it is possible to connect an IR transmitter at all pins?
greeting
aycin

John Reveley said...

This IR library is so handy, I’ve created a control system using the IR Library on a Mega, utilising the Mega's serial outputs to control serial devices (My Marantz Receiver and Atlona HDMI Switcher) and the IR libarary to control the IR devices (Sony TV, Samsung Bluray player) I have 8 individual IR outputs (one PWM pin connected to the + side of all of the LED's via a resistor and a digital pin with a diode on the negative side for each LED, thus allowing a single LED is to be activated. I have written a conversion program on the mega to accept the Global Cache’ sendir command and have added sendrs (for serial 0,1,2,3) and sendrl (to drive relays) a typical ir command looks like :
sendir,1:1,1,40000,1,1,96,23,48,23,24,23,48,23,24,23,48,23,24,23,24,23,48,23,24,23,24,23,24,23,24,800
Check out the Global Cache’ website for the breakdown of this protocol.
Commands are sent over the Mega’s Ethernet port via Demo Pad software from my iPhone.

Soveliss Foraereth said...

I get these errors, they seem to be related to MATCH:

IRremote/IRremote.cpp.o: In function `MATCH(int, int)':
/Users/hope/Documents/Arduino/libraries/IRremote/IRremoteInt.h:176: multiple definition of `MATCH(int, int)'
sketch_jan13a.cpp.o:/Users/hope/Documents/Arduino/libraries/IRremote/IRremoteInt.h:176: first defined here
IRremote/IRremote.cpp.o: In function `MATCH_MARK(int, int)':
/Users/hope/Documents/Arduino/libraries/IRremote/IRremoteInt.h:177: multiple definition of `MATCH_MARK(int, int)'
sketch_jan13a.cpp.o:/Users/hope/Documents/Arduino/libraries/IRremote/IRremoteInt.h:177: first defined here
IRremote/IRremote.cpp.o: In function `MATCH_SPACE(int, int)':
/Users/hope/Documents/Arduino/libraries/IRremote/IRremoteInt.h:178: multiple definition of `MATCH_SPACE(int, int)'
sketch_jan13a.cpp.o:/Users/hope/Documents/Arduino/libraries/IRremote/IRremoteInt.h:178: first defined here

Michael Flaga said...

You have duplicate CPP files in the directories. The Arduino IDE does not use a MAKE, rather it compiles all cpp and ino files in the working and library directories. Some version controls (GIT) will make file.bak.cpp and leave them. this will interfere with the real file.cpp as they both have the same instances.

Aitor Inda said...

Hi. Sorry for my English.

I'm new in this, and I try to control one Sony TV whith an Arduino and a ir and I have a problem. I have two Sony tv, and the two original remotes, sends the same ir code and they work in the two TV.

The problem I have is that with Arduino I only can control one of them (the newest). The other TV seems to receive something (one led blink very low when I send the IR),but doesnt work.

Can anyone help me?

Mike said...

Ken, I would just like to thank you for your work on this project, it is much appreciated!

Tsoni said...

Hello.I am a bigginer in this area so I got some problems:
-I managed to set the receiver to get the code from a rc helicpter trasmitter, but all I ge in the serial monitor were impossible to understaand values :

UNKNOWN: BEA23CC0
UNKNOWN: BEA23CC0
UNKNOWN: BEA23CC0
UNKNOWN: BEA23CC0
UNKNOWN: BEA23CC0
UNKNOWN: A381B17A
UNKNOWN: 40ECE322
UNKNOWN: 40ECE322
UNKNOWN: 15CD9A68
UNKNOWN: 53E087CA
UNKNOWN: 709EC746
UNKNOWN: CAFDC726
UNKNOWN: F2B41972
UNKNOWN: DFFB6328
UNKNOWN: 4D8C3D8E
UNKNOWN: E8C95D8
UNKNOWN: BEA23CC0

I used tih code :
#include

const int RECV_PIN = 2;

IRrecv irrecv(RECV_PIN);

decode_results results;

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

void loop() {
if (irrecv.decode(&results)) {
if (results.decode_type == NEC) {
Serial.print("NEC: ");
} else if (results.decode_type == SONY) {
Serial.print("SONY: ");
} else if (results.decode_type == RC5) {
Serial.print("RC5: ");
} else if (results.decode_type == RC6) {
Serial.print("RC6: ");
} else if (results.decode_type == UNKNOWN) {
Serial.print("UNKNOWN: ");
}
Serial.println(results.value, HEX);
irrecv.resume(); // Receive the next value
}
}

so I would like to know how to decode those digits and how to turn them into a signal that I can use to control some motors for example- can you help me?
Thanks in advance

Michael Flaga said...

Yes, the library does not support decoding the RC HeliCoptor patterns, yet...
Hence it declares it unknown and display the raw values.

Aitor Inda said...

Hi! Sorry for my English.

I still have the same problem. I've been looking around and I found that the TV-b-gone for arduino turns off my old Sony TV. I searched into the code and I get the part of the library that turns off the TV, but I don't understand how the program handles the code.

This is the library:

const uint16_t code_na024Times[] PROGMEM = {
58, 60,
58, 2569,
118, 60,
237, 60,
238, 60,
};
const uint8_t code_na024Codes[] PROGMEM = {
0x69,
0x24,
0x10,
0x40,
0x03,
0x12,
0x48,
0x20,
0x80,
0x00,
};
const struct IrCode code_na024Code PROGMEM = {
freq_to_timerval(38462),
26, // # of pairs
3, // # of bits per index
code_na024Times,
code_na024Codes
};

Here you can find the code. http://www.arcfn.com/2010/11/improved-arduino-tv-b-gone.html

What is the relation betwen 0xA90(Sony OFF) and the above library?

I'm going crazy whith this.

Thank you!

Nicola said...

Hi Ken,

congratulations for your great job.
Unfortunately your library doesn't support Arduino Due yet. Do you have any plans to extend it for this new Arduino board?
Thanks,

Nicola

Toni said...

Hi.How am I to send signal to my samsung tv? the code I get when pressing the power button is something like FF05B9 (i dont exactly remember it now).I put it in the code like this


#include
IRsend irsend;

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

void loop() {
if (Serial.read() != -1) {
irsend.sendHEC(0xFFo5B9,12);
delay(100);
}
}


i can see the ir led lights up through my camera, but still anything won't happen with the tv.
can you help me???
also I need to identify the pin i have attached the led to, right? how do I d this here?
thanks

C. Weeks said...

I've been having a similar issue. The one thing I've noticed is that the IR LED that I have hooked to my 'duino is significantly dimmer than the one on my remote when I look at both through my phone's camera. I kind of gave up on it, other life issues came up and I kind of put the thing on the back burner. Now that I'm thinking about it again, I think I might look up how to properly hook up an IR LED to make it as bright or brighter than a standard remote's and see if that helps.

Anonymous said...

Does the library work with 56khz receiver ?

gratz said...

I believe Samsung TV's require the on command to be pulsed number of times before triggering a switch on. Also Toni your hex code contains a 'o' rather than '0'?

Frost369 said...

Is this library compatible with arduino due? I tried the sample program IRrecvDemo and got this compile error.

C:....\Desktop\Indicia\Projects\Arduino Due\arduino-1.5.1r2\libraries\IRremote\IRremote.cpp:23: fatal error: avr/interrupt.h: No such file or directory
compilation terminated.

I know interrupt.h is around. I am not an expert in programming, but I tried copying the avr folder into the IRremote directory and it fixed the interrupt.h, but there are still other errors associated with not finding filed or headers that I have.

Mat Kenny said...

Hi Ken,
Great library I am enjoying working with it. I am however stumped at the moment I am trying to make a network attached IR remote using A X-Board Relay (Leonardo compatable) http://www.dfrobot.com/index.php?route=product/product&product_id=837#.URDbhfKTXKc
The two relays operate a tv lift and then the TV is operated by sending raw data using your IR Library. My IR codes work normally (using a push button) but when I add ethernet the TV IR codes are incorrect it seems to only change the channel up any ideas as to what the problem could be. The relays work but they are also changing the channel up. Any ideas would be appreciated.

naveen said...

acuatually i am receiving IRrecv does not name a type.is there anysolution.why it is comming .plz help me

Кирилл Савинов said...
This comment has been removed by the author.
Кирилл Савинов said...
This comment has been removed by the author.
Anonymous said...

when i upload IRrecDemo from C:\arduino-1.0.3\libraries\IRremote of my computer,,,
c:/arduino-1.0.3/hardware/tools/avr/bin/../lib/gcc/avr/4.3.2/../../../../avr/bin/ld.exe: IRrecvDemo.cpp.elf section .text will not fit in region text
c:/arduino-1.0.3/hardware/tools/avr/bin/../lib/gcc/avr/4.3.2/../../../../avr/bin/ld.exe: region text overflowed by 50 bytes

this above error occur,, what shoul i do ? i want to use panasonic remote with my arduino

C. Weeks said...

I'm no expert but it looks like you need to clean up your directory structure since all of the directories add to the length of the file name. Why do you have it buried like that, anyway?

jonathan stewart said...

Hi iv been trying to get this simple ir translator to work so i can use unused buttons on my stereo remote to control my tv. This code runs however after receiving the proper code from the receiver remote the Arduino executes the code needed but then wont respond to other ir signals sent to it regardless of there value. The only way to get the Arduino to respond again is to reset it. Can someone explain to me why this isn't working?

Here is my code!!

#include

int RECV_PIN = 11;

IRrecv irrecv(RECV_PIN);
IRsend irsend;

decode_results results;

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


void loop() {

if (irrecv.decode(&results)) {
delay(500);
Serial.println(results.value,HEX);
// Receive the next value
if (results.value == 0x4B3420DF)
{
delay(1000);

irsend.sendSony(0x61A0F00F,32);
Serial.println("HORRAY!!");
delay(1000);
}
irrecv.resume();
}
}

Doctor Who said...

Hello!
I just tried out the updated code for your Infrared Remote Library for the Arduino on my Duemilanove and used the receiver that came with Sparkfun's remote control retail package. This was IRrecvDemo and it worked by telling me the numbers that were produced when I pressed any of the buttons on the enclosed keychain remote. Very impressed.

Jakki said...

Thank you so much for this library, made my day!

Huck Milton said...

Can you explain this? I erased and reinstalled the libraries reinstalled the IDE and tried it on 1.0.3 and 1.0.

IRremote\IRremote.cpp.o: In function `MATCH(int, int)':
/IRremoteInt.h:150: multiple definition of `MATCH(int, int)'
testir.cpp.o:C:\Users\Huck\Desktop\arduino-1.0.3\libraries\IRremote/IRremoteint.h:150: first defined here
IRremote\IRremote.cpp.o: In function `MATCH_MARK(int, int)':
/IRremoteInt.h:151: multiple definition of `MATCH_MARK(int, int)'
testir.cpp.o:C:\Users\Huck\Desktop\arduino-1.0.3\libraries\IRremote/IRremoteint.h:151: first defined here
IRremote\IRremote.cpp.o: In function `MATCH_SPACE(int, int)':
/IRremoteInt.h:152: multiple definition of `MATCH_SPACE(int, int)'
testir.cpp.o:C:\Users\Huck\Desktop\arduino-1.0.3\libraries\IRremote/IRremoteint.h:152: first defined here

Thanks.

Anonymous said...

Hi and thanks for the library :)
It work greate on my Arduino UNO that run ATMEGA328.

The problem is that I have same as
Diego have but I have 5V.

It run Leonardo with ATMega 32U4.

It have support for that but Pro Micro does not have any Pin 13.

I did try to just change the PIN in IRremoteInt.h. From 13 to 3 but nothing happend.
I maybe do something wrong but what I do not know.

Charles Edmondson said...

Has anyone ported this library code to the ChipKIT line of Arduino compatible boards? Need to add a channel or two of IR output to a control panel...

Charles Edmondson said...

Has anyone ported this code to the ChipKIT Max32 yet? I need to add a couple of channels to an existing control system...

Dave O said...

If I only need to receive IR codes (and not send), can I reclaim the use of *all* my PWM pins?

Full disclosure - I committed a design to PCB and have PWM outputs needed on Pins 3, 5, 6 and 9. If I choose Timer 2 in the library I lose PWM on 3 & 11. If I choose Timer 1, then I lose PWM on 9 & 10.

I figured that PWM was only needed by the IRremote library to *send* IR, but my experimentation doesn't seem to support that.

I went ahead and hacked the IRremote.cpp to remove all the IRSend and PWM stuff, but I still lose PWM on one set of pins.

Any ideas on *if* it's possible to hack the library to work around my issue? If so, any hints on how to go about it?

Thanks!

Dave O

Anonymous said...

In the spirit of Paul's port to the teensy, I have proof of concepts for the maple

https://github.com/manitou48/maple-IRremote

and for the DUE

https://github.com/manitou48/DUEZoo/tree/master/IRtest

thanks for the library

c2 said...

I am trying to use a Leonardo to control a JVC camcorder. I seem to be having SEND problmes. The RECEIVE puts up the expected FB85 and FB05 like clockwork. But the IR LED (or a substitute red LED) never even flicker. I tested the IR LED on a simple circuit and viewed through a cell phone camera, so it works great. I am connecting the IR LED through port 3 the PWM.
I am confused by the comments of "PWM on 13" or "#define TIMER_PWM_PIN 10" but I tried moving the jumper from 3 to 13 or to 10. I also edited #define TIMER_PWM_PIN 13 to 10 in IRremoteInt.h and tested the LED jumper in 3, 13 and 10 without success. In 13 I get a constant flicker, and to test if that was just the nature of port 13 i changed the delayMicroseconds from 50 to 5000, and the flicker seems unimpressed.

Lauszus said...

@c2
You have to connect the LED to pin 13 if you are using an Arduino Leonardo. See this pull request I sent a while back: https://github.com/shirriff/Arduino-IRremote/pull/13/files.

c2 said...

It is all good. I did a poor job of checking if pin 13 was working. Once I sent a JVC command like FB85 to my camcorder, everything became clear. Thanks!

RON BUCHWALD said...

459

RON BUCHWALD said...

HI KEN MAYBE YOU CAN HELP. i NEED TO KNOW WHAT CODE TO TELL MY 2313 AMTEL CHIP, PROGRAMED WITH THE ARDUINO UNO BD. THAT i WANT THE PROGRAM TO STOP AND HOLD THE VALUES AT THIS POINT. ie THE CODE IS A FADING PGM FOR AN r g b LED STRIP. ALL HARDWARE WORKS FINE, BUT i DON'T KNOW WHAT TO WRITE TO SAY STOP HOLD THIS SET OF VALUES...pLEASE CONTACT ME FoR MORE INFO i AM HAVING TROUBLE GETTING INTO SITES SUCH AS YOURS AND NEED SOME HELP. mY E-MAIL IS [email protected] Please help if you can. Ron.

RON BUCHWALD said...

I am sorry about the capt letters, I am not yelling , just a typo error. Ron.

Anonymous said...

I just want to say great job. i am realy impressed.

Michael Flaga said...

I have added support to my GITHUB FORK https://github.com/mpflaga/Arduino-IRremote.git for MagiQuest wands, both transmit and receive.

Michael Flaga said...

I have added support to my GITHUB FORK https://github.com/mpflaga/Arduino-IRremote.git for several popular small 3.5ch helicopters. I have seen requests for these inexpensive toys. The library will both receive or transmit the different channels. For transmitting there is an example, in which you connect several joysticks and buttons to the Arduino's analog input to emulate the remote.
This will allow you to either use the Arduino to receive the remotes signals. Or drive the helicopter from the Arduino.
Have fun.

Anonymous said...

Thank you very much for this excellent library and documentation!

Ziqumu PC said...

Hello, i've a problem with a remote : it control my air conditioning. It send each time all data to the air conditioning so the buffer receiver need to be bigger than 256. So I edit RAWBUF constant, and when i put this constant to a number bigger than 256, the script say there is only 72 data, whereas when RAWBUF=255, the script say there 255 datas (there is more datas, but the buffer is too small) And I see no variables than can't be bigger than 256.

Thanks for your help.

Ziqumu PC said...

I found the solution for my problem :
rawlen type (uint8_t) is too small for more than 256, so i need to replace it by unsigned short int
So actually I receive all data (584 datas ! ) when _GAP> 35000.
If _GAP is lower, I didn't receive all datas. But it's not a problem because it work perfectly when _GAP> 35000

Youssef Fotouh said...

greetings,
i have a Mega-ADK board and i'm trying to get multi output on infrared transmitters so for example if pin 9 works as default for the infrared transmitter, i want also to use other PWM pins and control in the my program the pins in which i send IR commands,
so how can i do this?

Anonymous said...

Thanks so much for the great job!

I want to decode a SAMSUNG air conditioner remote (db93-11115k) but the library doesn't recognize the ir codes. I have added the code for decoding Samsung TV remote and it works very well. The air conditioner remote is not yet decoded!

For Samsung TV:
Decoded SAMSUNG: E0E040BF (32 bits)
Decoded SAMSUNG: E0E040BF (32 bits)

For air conditioner:
FFFFFFFF
FFFFFFFF (0 bits)
Raw (100): -8850 500 -1500 500 -500 550 -400 550 -450 500 -500 500 -500 500 -450 550 -450 550 -450 500 -1450 550 -450 500 -500 500 -450 550 -450 500 -1450 550 -500 500 -1450 500 -1500 500 -1450 550 -1400 550 -1450 550 -450 500 -1450 500 -1450 550 -450 550 -1450 550 -400 550 -1450 550 -1450 500 -450 550 -450 550 -1450 500 -450 550 -450 550 -450 500 -1450 550 -450 550 -450 550 -400 550 -450 550 -450 550 -400 550 -450 550 -450 550 -450 500 -500 500 -500 500 -450 550 -450 500
FFFFFFFF
FFFFFFFF (0 bits)
Raw (100): -8900 500 -1500 500 -450 550 -450 500 -500 500 -450 550 -450 550 -450 500 -500 500 -450 550 -1450 500 -450 550 -450 550 -450 550 -450 500 -1450 550 -450 500 -1500 500 -1450 550 -1450 500 -1450 550 -1400 550 -450 550 -1450 550 -1400 550 -450 500 -1450 550 -450 550 -1450 500 -1450 550 -450 500 -500 500 -1450 550 -450 550 -450 550 -400 550 -1450 550 -400 550 -450 550 -450 500 -500 500 -500 500 -450 550 -450 550 -450 500 -500 500 -450 550 -450 550 -450 500 -500 550
FFFFFFFF
FFFFFFFF (0 bits)
Raw (100): -8850 500 -1500 500 -450 550 -450 550 -450 550 -450 500 -450 550 -450 550 -450 550 -400 550 -1450 500 -500 550 -400 550 -450 500 -500 550 -1400 550 -450 550 -1450 500 -1450 550 -1450 550 -1400 550 -1450 550 -400 550 -1450 550 -1400 550 -450 500 -1450 550 -450 550 -1450 500 -1450 550 -450 550 -450 550 -1400 550 -450 500 -500 550 -400 550 -1450 550 -450 500 -450 550 -450 550 -450 550 -450 500 -450 550 -450 550 -450 550 -450 500 -500 500 -450 550 -450 550 -450 550
FFFFFFFF
FFFFFFFF (0 bits)
Raw (100): -8850 550 -450 500 -1500 500 -500 450 -500 500 -500 500 -500 500 -450 500 -500 500 -500 500 -1450 500 -500 500 -500 500 -1500 550 -400 550 -450 500 -1500 500 -1450 500 -1450 500 -1500 500 -1450 500 -500 500 -450 550 -450 500 -500 500 -500 500 -500 500 -450 500 -550 500 -450 550 -450 500 -500 500 -450 500 -500 500 -500 500 -450 550 -450 500 -500 500 -500 500 -450 500 -500 500 -500 500 -500 500 -450 500 -550 450 -500 550 -450 550 -450 500 -450 550 -450 550

Can anyone help me to decode these raw data?

Lauszus said...

@Anonymous
The values comes in pairs.
The first two values -8850 500 are the header.
This sequence -1500 500 is a 1.
And finally: -500 550 is a 0.

Remember that these values can differ a bit, that's why you will see a sequence like:
-1450 550
But that's just a 1 too.

It shouldn't be that hard to modify the library in order to decode this.

Regards
Lauszus

Youssef Fotouh said...

hello again,
sorry if my question wasn't clear.
i'm trying to use multi-infrared transmitters in my arduino adk and control these transmitters in my code, where i want to control which transmitter send the specific output.

Clueless said...

Hello all!

First off, I'm not much aware of workings of remotes and the signal decoding process. So, pardon me if this is a dumb question.

I connected an AX-1838HS IR receiver to the 19th pin of a Mega 2560.
Uploaded the "IRrecvDemo" code.
I got a seemingly random data string (of 8 digits -hex) and a number (3 digits -hex) -which I think is the number I should be concentrating on- repeated 2 to 4 times. All for a one button press (on a Sony remote)
The random number does not appear always.

I added a 250ms delay before resuming the receiver.
At a button press, now only the first received data is shown (naturally). But a random number comes every now and then.
If the time interval between pressing buttons is small, the random data string never seem to come.

______________
Ex:
Power button_
5C25F964
A90
A90
A90
A90

Again Power button_
A90
A90
A90

One_
54B92EBE
10
10

Two_
810
810
810
810
______________
Tried a Panasonic remote. Same problem.

Now I can write a code to go around this problem if this is natural, which I doubt. So what is happening? And what should I do?

Thanks. :)

Clueless said...

Adding to my previous comment..

Arduino IDE version: 1.0.4

"IRrecv" code: https://github.com/shirriff/Arduino-IRremote/blob/master/examples/IRrecvDemo/IRrecvDemo.ino

(RECV_PIN is 19 instead of 11)

Ken Shirriff said...

Hi Clueless. The easiest solution would be to ignore the random values (which look like NEC) and use the 3-digit values (which look like Sony). You can check the type after the decode and discard it if it's not a Sony value. It could be your remote is sending multiple codes, or it could be the decode algorithm is picking up some noise.

Clueless said...

Thank you for the fast reply. :)

I suppose I can do that. Though it will waste little bit of system resources.
I used a different remote (I bought for this project specifically) and it generates totally random data strings.
I even added a pull-up resistor and a 104 between VCC, GND (The proper way to connect according to the data sheet). No luck.
Remote: http://www.pagaria.co.in/images/6883e.jpg

Youssef Fotouh said...

how can i use more than one pulse modulation pins to send infrared signals by more than one transmitter at the same time.
for example if i executed sendSony(0xa12,12) i get output at pin 9 and pin 5 for example at the same time?

Rawan Hij said...

Hi,I'm wanting to use this library to control my Acer projector.But the it print to me unknown signal,can you tell me the reason for this message

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

hello, i'm trying to control my air conditioner from an arduino UNO by using the IRremote library.
at first, i try to know the format IR decoding of the remote control,
Result: UNKNOWN

so i try to decode my IR signal 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
}

int c = 1;

void dump(decode_results *results) {

int count = results->rawlen;
Serial.println(c);
c++;
Serial.println("For IR Scope: ");
for (int i = 1; i < count; i++) {

if ((i % 2) == 1) {
Serial.print("+");
Serial.print(results->rawbuf[i]*USECPERTICK, DEC);
}
else {
Serial.print(-(int)results->rawbuf[i]*USECPERTICK, DEC);
}
Serial.print(" ");
}
Serial.println("");
Serial.println("For Arduino sketch: ");
Serial.print("unsigned int raw[");
Serial.print(count, DEC);
Serial.print("] = {");
for (int i = 1; i < count; i++) {

if ((i % 2) == 1) {
Serial.print(results->rawbuf[i]*USECPERTICK, DEC);
}
else {
Serial.print((int)results->rawbuf[i]*USECPERTICK, DEC);
}
Serial.print(",");
}
Serial.print("};");
Serial.println("");
Serial.print("irsend.sendRaw(raw,");
Serial.print(count, DEC);
Serial.print(",38);");
Serial.println("");
Serial.println("");

}

void loop() {
if (irrecv.decode(&results)) {
dump(&results);
Serial.println(results.value, HEX);
irrecv.resume(); // Receive the next value
}
}
--------------------------------
Result:
1
For IR Scope:
+4350 -4300 +550 -1600 +550 -500 +600 -1550 +650 -1500 +550 -550 +600 -450 +650 -1500 +550 -550 +550 -500 +550 -1600 +650 -450 +600 -450 +600 -1550 +550 -1600 +550 -550 +600 -1550 +550 -1600 +550 -500 +550 -1600 +550 -1600 +550 -1600 +550 -1600 +600 -1550 +600 -1550 +550 -500 +650 -1500 +650 -450 +600 -450 +550 -550 +550 -500 +650 -450 +550 -500 +600 -500 +550 -550 +600 -1500 +600 -500 +550 -1600 +600 -1550 +550 -550 +500 -550 +550 -1600 +600 -1550 +600 -450 +600 -1550 +600 -500 +550 -500 +650 -1500 +600 -1550 +550
For Arduino sketch:
unsigned int raw[100] = {4350,4300,550,1600,550,500,600,1550,650,1500,550,550,600,450,650,1500,550,550,550,500,550,1600,650,450,600,450,600,1550,550,1600,550,550,600,1550,550,1600,550,500,550,1600,550,1600,550,1600,550,1600,600,1550,600,1550,550,500,650,1500,650,450,600,450,550,550,550,500,650,450,550,500,600,500,550,550,600,1500,600,500,550,1600,600,1550,550,550,500,550,550,1600,600,1550,600,450,600,1550,600,500,550,500,650,1500,600,1550,550,};
irsend.sendRaw(raw,100,38);
DC4C5474

after that i try to send the decoded signal to my air conditioner by using this code:
-----------------------------

#include

IRsend irsend;
unsigned int raw[100] = {4350,4300,550,1600,550,500,600,1550,650,1500,550,550,600,450,650,1500,550,550,550,500,550,1600,650,450,600,450,600,1550,550,1600,550,550,600,1550,550,1600,550,500,550,1600,550,1600,550,1600,550,1600,600,1550,600,1550,550,500,650,1500,650,450,600,450,550,550,550,500,650,450,550,500,600,500,550,550,600,1500,600,500,550,1600,600,1550,550,550,500,550,550,1600,600,1550,600,450,600,1550,600,500,550,500,650,1500,600,1550,550,};
void setup()
{
Serial.begin(9600);
}

void loop() {
if (Serial.read() != -1) {
irsend.sendRaw(raw,100,38);
Serial.println("Sending......");
}
}
-----------------------------
but unfortunately, the air conditioner do not take any action.

i need a help plz.....

information: the remote control type is R51M/E (image of remote controle: http://www.codistec.com/219-large_default/remote-controler-r51m-e-bge.jpg)

amen_i said...

Hi,
@Tiago Rosolen: due to your publication on February 9, 2012 at 10:39 AM:
First of all thankyou Ken for this great info.I had a huge problem with split air conditioners. They simply never worked. It has been a few weeks but a finally got it.If any of you want to control midea, fujitsu or electrolux AC here's the tip:
1 - The buffer is to shor for this codes, change it to 200 in the very end of the IRRemote.h
2 - This remotes uses 1.25uS tick so you have to change USECPERTICK to 10 in this same file.
Works great now.

i want to control a midea remote, i follow the two steps (1 and 2) but until now i can't control my air conditioner....
please i need a help, can you guide me to find a solution...
i am waiting your reply

Rohin G said...

Hi Ken,
This is an amazing project and has helped many people. This is the best one i have ever seen.

But, however, saying that, i seem to get some kind of noise on the IR Reciever or something, when my RGB LED is connected to pin 3, 4, 5.

I had read elsewhere, and on this page saying that your code uses timer 2 => i won't be abe to use Those pins? Is that why i'm getting noise on my reciever pin? i checked using serial that, whenever one of the pin's are on. The IR Receiver keeps recieveing randomn values.
So, can you just tell me which pin's are safe to use with your library?

Any help is appreciated.

Alfredo said...

Hi Ken,
I have used your library to build a remote focuser for my telescope using an Arduino,IR receiver and a stepper motor. The remote controller was from an old Creative Soundblaster card and uses the NEC protocol. It works perfectly.
Now I bought a Canon EOS M camera with a simple remote controller model RC-6 which, I assume, is also the protocol used. I would like to use Arduino to build up an application to take photos at predefined intervals, but to do this I need to decode the code sent
by the RC-6 controller. I have tried to decode it using both a TSOP1538 receiver (38 KHz) and a TSOP34836 one which works at 36KHz.
No way: apparently Arduino does not receive any signal. There is no led blinking when I press the RC-6 controller.
Any suggestion from you or other
friends up there?
Alfredo

Alfredo said...

This is a followup to my post of yesterday concerning Canon RC6 remote controller.
Apparently the RC6 RC has nothing to do with the RC6 protocol.
I found a simple solution to my problem in this site:

http://controlyourcamera.blogspot.it/2010/01/infrared-controlled-timelapse.html

I have tried it and it works.
Hope this may help others.

Alfredo

steve said...

Thanks for the library. I wonder if anyone here can point me towards solving a problem I'm having:
I have an Arduino Uno r3
I can receive remote codes fine but I can't send IR
I have tested my IR LEDs are working using a camera and running them off pin13. They work.
When I use a camera, the IR LED on Pin3 does not illuminate using any of the IRSendDemo_test or any of the other tests. I tried a regular LED, that doesn't light up either.
Should I be able to see the IR flashing with the camera?
Thanks for any tips

steve said...

Got it! For anyone else, the IR was very dim when sending a signal.
I used http://arduino.cc/en/Tutorial/Fading to test an LED on pin3, then the same code to test the IR (i could see it clearly).
Then retried using one of the test libraries and realised I could just about see some flickers of output.

Alberto Piccioli said...

Hello, I cannot decode a SAMSUNG aircond remote. I changed the buffer size to 200 and now I get raw data:

Raw (116): -8800 550 -500 550 -1400 550 -450 500 -500 550 -400 550 -500 500 -450 550 -450 500 -500 500 -1450 550 -450 550 -450 550 -1400 550 -1450 500 -500 550 -1400 550 -1450 500 -1450 550 -1450 500 -1450 500 -500 550 -450 500 -500 550 -400 550 -450 550 -450 500 -500 500 -450 550 -450 550 -450 550 -450 550 -400 550 -450 550 -450 500 -500 500 -500 500 -500 500 -450 550 -450 550 -450 500 -500 550 -400 550 -450 550 -450 500 -500 500 -450 550 -450 550 -450 550 -450 550 -400 550 -450 550 -450 500 -500 500 -500 500 -1450 550 -1450 500 -2950 3000

It seems that there is:
1) an header (-8800 550)
2) 56 bits
3)a trailer (-2950 3000)

for each keyboard (probably the remote send all the information every time).

I start to write a function IRrecv::decodeSamsungAC but if I check irparams.rawlen I get always only 2!

It seems that the decoder goes in STATE_STOP after two mark/space.

Any suggestion?



My previous post:
April 15, 2013 at 10:29 AM
Anonymous said...
Thanks so much for the great job!

I want to decode a SAMSUNG air conditioner remote (db93-11115k) but the library doesn't recognize the ir codes. I have added the code for decoding Samsung TV remote and it works very well. The air conditioner remote is not yet decoded!

For Samsung TV:
Decoded SAMSUNG: E0E040BF (32 bits)
Decoded SAMSUNG: E0E040BF (32 bits)

For air conditioner:
FFFFFFFF
FFFFFFFF (0 bits)
Raw (100): -8850 500 -1500 500 -500 550 -400 550 -450 500 -500 500 -500 500 -450 550 -450 550 -450 500 -1450 550 -450 500 -500 500 -450 550 -450 500 -1450 550 -500 500 -1450 500 -1500 500 -1450 550 -1400 550 -1450 550 -450 500 -1450 500 -1450 550 -450 550 -1450 550 -400 550 -1450 550 -1450 500 -450 550 -450 550 -1450 500 -450 550 -450 550 -450 500 -1450 550 -450 550 -450 550 -400 550 -450 550 -450 550 -400 550 -450 550 -450 550 -450 500 -500 500 -500 500 -450 550 -450 500
FFFFFFFF
FFFFFFFF (0 bits)
Raw (100): -8900 500 -1500 500 -450 550 -450 500 -500 500 -450 550 -450 550 -450 500 -500 500 -450 550 -1450 500 -450 550 -450 550 -450 550 -450 500 -1450 550 -450 500 -1500 500 -1450 550 -1450 500 -1450 550 -1400 550 -450 550 -1450 550 -1400 550 -450 500 -1450 550 -450 550 -1450 500 -1450 550 -450 500 -500 500 -1450 550 -450 550 -450 550 -400 550 -1450 550 -400 550 -450 550 -450 500 -500 500 -500 500 -450 550 -450 550 -450 500 -500 500 -450 550 -450 550 -450 500 -500 550
FFFFFFFF
FFFFFFFF (0 bits)
Raw (100): -8850 500 -1500 500 -450 550 -450 550 -450 550 -450 500 -450 550 -450 550 -450 550 -400 550 -1450 500 -500 550 -400 550 -450 500 -500 550 -1400 550 -450 550 -1450 500 -1450 550 -1450 550 -1400 550 -1450 550 -400 550 -1450 550 -1400 550 -450 500 -1450 550 -450 550 -1450 500 -1450 550 -450 550 -450 550 -1400 550 -450 500 -500 550 -400 550 -1450 550 -450 500 -450 550 -450 550 -450 550 -450 500 -450 550 -450 550 -450 550 -450 500 -500 500 -450 550 -450 550 -450 550
FFFFFFFF
FFFFFFFF (0 bits)
Raw (100): -8850 550 -450 500 -1500 500 -500 450 -500 500 -500 500 -500 500 -450 500 -500 500 -500 500 -1450 500 -500 500 -500 500 -1500 550 -400 550 -450 500 -1500 500 -1450 500 -1450 500 -1500 500 -1450 500 -500 500 -450 550 -450 500 -500 500 -500 500 -500 500 -450 500 -550 500 -450 550 -450 500 -500 500 -450 500 -500 500 -500 500 -450 550 -450 500 -500 500 -500 500 -450 500 -500 500 -500 500 -500 500 -450 500 -550 450 -500 550 -450 550 -450 500 -450 550 -450 550

Can anyone help me to decode these raw data?

April 19, 2013 at 11:53 AM
Lauszus said...
@Anonymous
The values comes in pairs.
The first two values -8850 500 are the header.
This sequence -1500 500 is a 1.
And finally: -500 550 is a 0.

Remember that these values can differ a bit, that's why you will see a sequence like:
-1450 550
But that's just a 1 too.

It shouldn't be that hard to modify the library in order to decode this.

Regards
Lauszus

Zubin said...

hi ken,
i wanted to hook up my IR led on a different pin than digital pin 3 for some reason(it will still be a PWM pin) how do I do this?
thanks in advance!

c2 said...

On March 27, 2013 at 6:10 AM I received great advice to use pin 13 on Leonardo. Next, I want to complicate things by sending 2 separate command sequences to 2 different JVC cameras, so I would like to use both ports 13 and 10 for PWM commands. Or pin 6 or 3. I don't see where the pin is called out so that I can control 2 streams. Is there an easy way?

Anonymous said...

You can send out both streams on one IR Led

c2 said...

Sorry, I wasn't clear. I want to drive 2 IR LEDs, each with unique command strings, to 2 different cameras. I am trying to capture 2 angles of the same action. So I can start and stop simultaneously, but zoom separately. Have a pot for each camera, and a third pot for simultaneous zoom.

steve said...

@c2 my electronic skills are are weak. Could you have both leds on pin 3 but have a switch after them so that only one at a time is connected to ground?

c2 said...

I see several options. I think you are correct that I could put a relay on one of the IR LED lines to cut it in or out. Or I could use a second Arduino to drive each IR LED separately and use a pot connected to both Arduinos' analog port and use switches to control the configurations. What I thought would be the more elegant solution would be to have one Arduino and IR LEDs connected to 2 PWM ports. The signals on those 2 ports would have the Pulse Width Modulation signals, and in my application either the same PWM signal goes to both or only one receives PWM signal, avoiding having more than one clocking signal. But I am having trouble looking through the IR library for where the PWM port is identified. Part of the problem is I am using Leonardo, which seems to have odd port assignments. I suppose I could use a transistor to act as a relay, another possibility.

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

Hi Ken,

Thanks for this great library. With this library I can happily control my Samsung TV and TV cable.
Unfortunately, I doesnt work with my sharp AC. still using the same method with my tv and tv cable (using raw data method- substract the first data, then do negation for all the negative number).After look for your huge comment in this page, only few people can successfully control their AC.
Any tips for me how to do this? I already increase the RAWBUF from 100 to 300. But still cant do it.
I will happily donate if this can work because this is the last missing piece for my home automation.
Looking forward to hear your comment about this.

Thanks

francesco gargaro said...

hi i used for my project a TSOP2238 to receive ir signal from my air conditioning....i receive,when i push ON:
64800004
FFFFFFFF

and pushing OFF:
64800000
FFFFFFFF

therefore i want only reply this code to start my air conditioning...Can i do this?

francesco gargaro said...

sometimes pushing ON i receive:

Received unknown code, saving as raw
m3350 s1750 m400 s1300 m350 s1350 m400 s450 m400 s500 m350 s500 m350 s1350 m400 s450 m400 s450 m400 s1350 m350 s1350 m350 s500 m350 s1350 m350 s500 m350 s500 m400 s1300 m400 s1300 m400 s500 m350 s1350 m350 s1350 m400 s450 m400 s450 m400 s1350 m350 s500 m350 s500 m350 s1350 m400 s450 m350 s550 m350 s500 m350 s500 m350 s500 m400 s450 m400 s450 m400 s500 m350 s500 m350 s500 m350 s500 m400 s450 m400 s500 m350 s500 m350 s500 m350 s500 m400 s500 m350 s500 m350 s500 m350 s500 m350 s500 m400 s450 m400 s500 m350

«Oldest ‹Older   401 – 600 of 876   Newer› Newest»