RuiViana

ReadRaw

Oct 14th, 2016
138
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <IRremote.h>
  2.  
  3. int RECV_PIN = 6;
  4.  
  5. IRrecv irrecv(RECV_PIN);
  6. IRsend irsend;
  7.  
  8. boolean recording = true;
  9. decode_results results;
  10.  
  11. void setup()
  12. {
  13.   Serial.begin(9600);
  14.   irrecv.enableIRIn(); // Start the receiver
  15. }
  16.  
  17. void loop()
  18. {
  19.   if (recording)
  20.   {
  21.     if (irrecv.decode(&results))
  22.     {
  23.        Serial.println(results.value,HEX);
  24.        //Serial.println(results.bits,BIN);
  25.       Serial.println("IR code recorded!");
  26.       //irrecv.resume(); // Receive the next value
  27.       Serial.print("Recorded ");
  28.       Serial.print(results.rawlen);
  29.       Serial.println(" intervals.");
  30.       recording = false;
  31.     }
  32.   } else {
  33.     // replay mode
  34.     Serial.println("Sending recorded IR signal!");
  35.     irsend.sendRaw((unsigned int*) results.rawbuf, results.rawlen, 38);
  36.     delay(2000);
  37.   }
  38. }
RAW Paste Data