/
IR_Recieve
39 lines (38 loc) · 1.42 KB
/
IR_Recieve
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
/*awRacv. ino Example sketch for IRLib2
Illustrate how to capture raw timing values for an unknow protocol.
You will capture a signal using this sketch. It will output data the
serial monitor that you can cut and paste into the "rawSend. ino"
sketch.
*/
// Recommend only use IRLibRecvPCI or IRLibRecvLoop for best results
#include <IRLibRecvPCI.h>
IRrecvPCI myReceiver(2); // pin number for the receiver
void setup()
{
Serial.begin(9600);
delay(2000);
while (!Serial); // delay for Leonardo.
myReceiver.enableIRIn(); // Start the receiver
Serial.println(F("Ready to receive IR signals"));
}
void loop()
{
// Continue looping until you get a complete signal received
if (myReceiver.getResults())
{
Serial.println(F("Do a cut-and-paste of the following lines into the "));
Serial.println(F("designated location in rawSend. ino"));
Serial.print(F("\n#define RAW_DATA_LEN "));
Serial.println(recvGlobal.recvLength, DEC);
Serial.print(F("uint16_t rawData [RAW_DATA_LEN]={\n\t"));
for (bufIndex_t i = 1; i < recvGlobal.recvLength; i++)
{
Serial.print(recvGlobal.recvBuffer[i], DEC);
Serial.print(F(", "));
if ((i % 8) == 0)
Serial.print(F("\n\t"));
}
Serial.println(F("1000};")); // Add arbitrary trailing space.
myReceiver.enable IRIn(); // Restart receiver
}
}