Hi!
I just checked, you can use the rawbuf from IR class which is of type unsigned int*.
After changing the function to unsigned int, I added the code to the IRrecvDump. See the ADDED comments to see what lines where added.
I created the RawReceive variable and it is filled as the raw are being received.
After that, the Arrays are compared and then do what it have to do.
/*
* IRremote: IRrecvDump - dump details of IR codes with IRrecv
* An IR detector/demodulator must be connected to the input RECV_PIN.
* Version 0.1 July, 2009
* Copyright 2009 Ken Shirriff
* http://arcfn.com
* JVC and Panasonic protocol added by Kristian Lauszus (Thanks to zenwheel and other people at the original blog post)
* LG added by Darryl Smith (based on the JVC protocol)
*/
#include <IRremote.h>
int RECV_PIN = 11;
IRrecv irrecv(RECV_PIN);
decode_results results;
/* ---- START ADDED ----*/
unsigned int Raw1[48]= {-5800, 100, -3650, 50, -1150, 100, -950, 100, -1550, 100, -50, 300, -1150, 100, -700, 200, -450, 150, -1500, 50, -1150, 2600, -500, 750, -450, 800, -500, 750, -350, 100, -50, 750, -500, 750,-500, 700, -500, 750, -500, 1350, -550, 700, -500, 750, -500, 750, -550, 500,};
unsigned int RawReceived[48];
//Function to compare Unsigned Int Array
// Returns true when they are equal and false otherwise
bool CompareIntArray(unsigned int* Array1, unsigned int* Array2, int BitsToCompare){
for(int n = 0; n<BitsToCompare; n++){
if(Array1[n]!=Array2[n])
return false;
}
return true;
}
/* ---- END ADDED ----*/
void setup()
{
Serial.begin(115200);
irrecv.enableIRIn(); // Start the receiver
}
// Dumps out the decode_results structure.
// Call this after IRrecv::decode()
// void * to work around compiler issue
//void dump(void *v) {
// decode_results *results = (decode_results *)v
void dump(decode_results *results) {
int count = results->rawlen;
if (results->decode_type == UNKNOWN) {
Serial.print("Unknown encoding: ");
}
else if (results->decode_type == NEC) {
Serial.print("Decoded NEC: ");
}
else if (results->decode_type == SONY) {
Serial.print("Decoded SONY: ");
}
else if (results->decode_type == RC5) {
Serial.print("Decoded RC5: ");
}
else if (results->decode_type == RC6) {
Serial.print("Decoded RC6: ");
}
else if (results->decode_type == PANASONIC) {
Serial.print("Decoded PANASONIC - Address: ");
Serial.print(results->panasonicAddress,HEX);
Serial.print(" Value: ");
}
else if (results->decode_type == LG) {
Serial.print("Decoded LG: ");
}
else if (results->decode_type == JVC) {
Serial.print("Decoded JVC: ");
}
Serial.print(results->value, HEX);
Serial.print(" (");
Serial.print(results->bits, DEC);
Serial.println(" bits)");
Serial.print("Raw (");
Serial.print(count, DEC);
Serial.print("): ");
memset(RawReceived,0,sizeof(RawReceived)); //<--- ADDED
for (int i = 0; i < count; i++) {
if ((i % 2) == 1) {
Serial.print(results->rawbuf[i]*USECPERTICK, DEC);
RawReceived[i] = results->rawbuf[i]*USECPERTICK; //<--- ADDED
}
else {
Serial.print(-(int)results->rawbuf[i]*USECPERTICK, DEC);
RawReceived[i] = -(int)results->rawbuf[i]*USECPERTICK; //<--- ADDED
}
Serial.print(" ");
}
Serial.println("");
/* ---- START ADDED ----*/
if(CompareIntArray(Raw1,RawReceived,48)){ //<--- ADDED
//Do Stuff
}
/* ---- END ADDED ----*/
}
void loop() {
if (irrecv.decode(&results)) {
Serial.println(results.value, HEX);
dump(&results);
irrecv.resume(); // Receive the next value
}
}