Skip to content

Commit e9d43f7

Browse files
committed
Create IRsendRawDemo
As sendRaw is a very popular methos of sending unknown or AC signals, I though it would be very useful to include and example of same with the library. The code in this new example is tested and verified as working with the latest Master.
1 parent d433744 commit e9d43f7

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed

examples/IRsendRawDemo

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
/*
2+
* IRremote: IRsendRawDemo - demonstrates sending IR codes with sendRaw
3+
* An IR LED must be connected to Arduino PWM pin 3.
4+
* Version 0.1 July, 2009
5+
* Copyright 2009 Ken Shirriff
6+
* http://arcfn.com
7+
*
8+
* IRsendRawDemo - added by AnalysIR (via www.AnalysIR.com), 24 August 2015
9+
*
10+
* This example shows how to send a RAW signal using the IRremote library.
11+
* The example signal is actually a 32 bit NEC signal.
12+
* Remote Control button: LGTV Power On/Off.
13+
* Hex Value: 0x20DF10EF, 32 bits
14+
*
15+
* It is more efficient to use the sendNEC function to send NEC signals.
16+
* Use of sendRaw here, serves only as an example of using the function.
17+
*
18+
*/
19+
20+
21+
#include <IRremote.h>
22+
23+
IRsend irsend;
24+
25+
void setup()
26+
{
27+
28+
}
29+
30+
void loop() {
31+
int khz = 38; // 38kHz carrier frequency for the NEC protocol
32+
unsigned int irSignal[] = {9000, 4500, 560, 560, 560, 560, 560, 1690, 560, 560, 560, 560, 560, 560, 560, 560, 560, 560, 560, 1690, 560, 1690, 560, 560, 560, 1690, 560, 1690, 560, 1690, 560, 1690, 560, 1690, 560, 560, 560, 560, 560, 560, 560, 1690, 560, 560, 560, 560, 560, 560, 560, 560, 560, 1690, 560, 1690, 560, 1690, 560, 560, 560, 1690, 560, 1690, 560, 1690, 560, 1690, 560, 39416, 9000, 2210, 560}; //AnalysIR Batch Export (IRremote) - RAW
33+
34+
irsend.sendRaw(irSignal, sizeof(irSignal) / sizeof(irSignal[0]), khz); //Note the approach used to automatically calculate the size of the array.
35+
36+
delay(5000); //In this example, the signal will be repeated every 5 seconds, approximately.
37+
}

0 commit comments

Comments
 (0)