2

I am using the following code to send an IR signal:

#include <IRremote.h>
 IRsend irsend;

void setup() {

}

void loop() {

    unsigned int IRsignal[] = {86,88,86,88,174,86,88,88,86,88,86,86,88,86,88,86,88,174,86,88,174,86,88,2336,90,86,88,86,174,88,86,88,86,88,86,88,86,88,86,88,86,174,88,86,174,88,86,0};

    irsend.sendRaw(IRsignal, 48, 40);

    delay(3000);

}

However, when I attach an IR receiver to another Arduino and take a look at the signal that is produced by the code above, I see this:

Received:

OFF     ON
332 usec, 460 usec
1040 usec, 280 usec
2680 usec, 260 usec
820 usec, 80 usec
400 usec, 260 usec
int IRsignal[] = {
// ON, OFF (in 10's of microseconds)
    46, 104,
    28, 268,
    26, 82,
    8, 40,
    26, 0};


Received: 

OFF     ON
39228 usec, 280 usec
1160 usec, 340 usec
2460 usec, 480 usec
440 usec, 500 usec
340 usec, 260 usec
int IRsignal[] = {
// ON, OFF (in 10's of microseconds)
    28, 116,
    34, 246,
    48, 44,
    50, 34,
    26, 0};

These numbers are not even close to the ones that are going in. There are far few pulses recorded, the duration is very inconsistent (the original code is almost entirely made up of 880-860um pulses) and even close to the original values. I must have made a serious mistake here. What happened?

UPDATE ==========================

I multiplied all of the values in the array by 10 and attempted to play/read the values using another Adruino with an IR sensor. I started to see better results. each pulse time was close to 88, 86, or 174 but they are still off by up to 10%. The related IR device is still unresponsive. Is there any other way to improve this?

Received: 

OFF     ON
29828 usec, 860 usec
900 usec, 820 usec
880 usec, 1700 usec
880 usec, 860 usec
880 usec, 840 usec
940 usec, 760 usec
840 usec, 880 usec
860 usec, 880 usec
860 usec, 860 usec
1740 usec, 840 usec
880 usec, 1700 usec
880 usec, 840 usec
6920 usec, 880 usec
860 usec, 860 usec
880 usec, 1680 usec
880 usec, 860 usec
900 usec, 820 usec
900 usec, 820 usec
880 usec, 840 usec
860 usec, 840 usec
960 usec, 740 usec
1760 usec, 880 usec
920 usec, 1620 usec
900 usec, 10680 usec
13580 usec, 8580 usec
8820 usec, 8680 usec
int IRsignal[] = {
// ON, OFF (in 10's of microseconds)
    86, 90,
    82, 88,
    170, 88,
    86, 88,
    84, 94,
    76, 84,
    88, 86,
    88, 86,
    86, 174,
    84, 88,
    170, 88,
    84, 692,
    88, 86,
    86, 88,
    168, 88,
    86, 90,
    82, 90,
    82, 88,
    84, 86,
    84, 96,
    74, 176,
    88, 92,
    162, 90,
    1068, 1358,
    858, 882,
    868, 0};
6
  • Possibly I have an out of date copy of IRremote.cpp, but in that file on my system IRsignal[] values are in microseconds, not tens of microseconds. Ie, sendRaw sends buf[i] values as-is to mark() and space(), which call delayMicroseconds() after enabling or disabling PWM. Apr 5, 2015 at 7:12
  • Are you sure it's a 40kHz signal, and not 38kHz?
    – Gerben
    Apr 5, 2015 at 12:25
  • @Gerben - no idea what the kHz is, how can I tell? Either way, the signal should still come across to the other Arduino as the same data set right?
    – Hoytman
    Apr 7, 2015 at 1:41
  • @jwpat7 - so it might work if I put an extra zero on each value (x10?)
    – Hoytman
    Apr 7, 2015 at 1:42
  • Most remotes and receivers use 38kHz. So if you send 40kHz to a 38kHz receiver, the signal might not be read entirely correct.
    – Gerben
    Apr 7, 2015 at 10:54

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Browse other questions tagged or ask your own question.