![20131208_001119](http://tech.yeesiang.com/wp-content/uploads/2013/12/20131208_0011191-150x150.jpg)
![20131208_001241](http://tech.yeesiang.com/wp-content/uploads/2013/12/20131208_001241-150x150.jpg)
![sketch.modified](http://tech.yeesiang.com/wp-content/uploads/2013/12/sketch.modified-1024x653.png)
![20131208_133548](http://tech.yeesiang.com/wp-content/uploads/2013/12/20131208_133548-1024x768.jpg)
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 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 |
/* * IRremote: IRrecvDemo - demonstrates receiving 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 */ #include <IRremote.h> int RECV_PIN = 11; IRrecv irrecv(RECV_PIN); decode_results results; void setup() { Serial.begin(9600); irrecv.enableIRIn(); // Start the receiver } void loop() { if (irrecv.decode(&results)) { long int decCode = results.value; String hexCode = String(decCode, HEX); String decodedSignal = decodeSignal(hexCode); if(decodedSignal != "unknown") { Serial.print("dec: "); Serial.print(hexCode); Serial.print("|"); Serial.print(decCode); Serial.print("|"); Serial.print(decodedSignal); Serial.println(); } // Serial.println(, HEX); irrecv.resume(); // Receive the next value } } String decodeSignal(String hex) { hex.toUpperCase(); if(hex == "FFA25D") return "power"; if(hex == "FF629D") return "mode"; if(hex == "FFE21D") return "mute"; if(hex == "FF22DD") return "play"; if(hex == "FF02FD") return "rewind"; if(hex == "FFC23D") return "forward"; if(hex == "FFE01F") return "eq"; if(hex == "FFA857") return "-"; if(hex == "FF906F") return "+"; if(hex == "FF6897") return "0"; if(hex == "FF9867") return "repeat"; if(hex == "FFB04F") return "usd"; if(hex == "FF30CF") return "1"; if(hex == "FF18E7") return "2"; if(hex == "FF7A85") return "3"; if(hex == "FF10EF") return "4"; if(hex == "FF38C7") return "5"; if(hex == "FF5AA5") return "6"; if(hex == "FF42BD") return "7"; if(hex == "FF4AB5") return "8"; if(hex == "FF52AD") return "9"; return "unknown"; } |