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