2 * IRremote: IRrecvDump - dump details of IR codes with IRrecv
3 * An IR detector/demodulator must be connected to the input RECV_PIN.
4 * Version 0.1 July, 2009
5 * Copyright 2009 Ken Shirriff
13 IRrecv irrecv(RECV_PIN);
15 decode_results results;
20 irrecv.enableIRIn(); // Start the receiver
23 // Dumps out the decode_results structure.
24 // Call this after IRrecv::decode()
25 // void * to work around compiler issue
26 //void dump(void *v) {
27 // decode_results *results = (decode_results *)v
28 void dump(decode_results *results) {
29 int count = results->rawlen;
30 if (results->decode_type == UNKNOWN) {
31 Serial.println("Could not decode message");
34 if (results->decode_type == NEC) {
35 Serial.print("Decoded NEC: ");
37 else if (results->decode_type == SONY) {
38 Serial.print("Decoded SONY: ");
40 else if (results->decode_type == RC5) {
41 Serial.print("Decoded RC5: ");
43 else if (results->decode_type == RC6) {
44 Serial.print("Decoded RC6: ");
46 Serial.print(results->value, HEX);
48 Serial.print(results->bits, DEC);
49 Serial.println(" bits)");
51 Serial.print("Raw (");
52 Serial.print(count, DEC);
55 for (int i = 0; i < count; i++) {
57 Serial.print(results->rawbuf[i]*USECPERTICK, DEC);
60 Serial.print(-(int)results->rawbuf[i]*USECPERTICK, DEC);
69 if (irrecv.decode(&results)) {
70 Serial.println(results.value, HEX);
72 irrecv.resume(); // Receive the next value