/* Modification of IRremoteESP8266, IRsendDemo, for Xfinity/Comcast XR2, (unpaired,) remote, the Sceptre TV remote, and, the Dingsun Volume control remote. The original development was on the Arduino, using IRLib2 and AnalysIR, and, http://www.johncon.com/john/archive/sprawACM0.txt. The only data structure modifications was to change "unsigned int" to "uint16_t" for ESP8266 compatibility. IRrecvDumpV2.ino was modified with "kTimeout = kMaxTimeoutMs", with manual settings of the end of IR stream to provide the same data structures. The pin numbers were changed for compatibility with IRremoteESP8266. Xfinity/Comcast XR2, (unpaired,) remote, and, Sceptre television remote codes, for the Arduino IRLib2 library, (based on the rawSend sketch from the IRLib2 library.) The codes were derived from the AnalysIR sketch, with the IR receiver, (a TSOP38338 was used for the development,) in the middle of a large desk, about 2" from the remote LED. Due to the size of the IR code data, at least an Arduino Mega, (an Elegoo EL-CB-003 MEGA 2560 R3 Board ATmega2560 ATMEGA16U2 was used for the development,) will be required. (A Genuine Arduino UNO was tested, also, with a reduced number of buttons represented.) The TSOP38338 IR receiver output pin, (pin 1 = OUT on the TSOP38338 data sheet,) is connected to the Arduino input pin 2, (both Arduino MEGA and UNO.) The IR LED circuit is connected to the Arduino MEGA pin 9~. The IR LED circuit is connected to the Arduino UNO pin 3~. This sketch is intended to use the xr2USB0, or, sprawUSB0 raw terminal program as a command line input program from the computer terminal. For reference, (from http://www.hifi-remote.com/wiki/index.php/XMP): XMP uses one burst pair to encode numbers 0 to 15, with a Mark ON duration of 210 uS, and a Space OFF duration of 760 + (n * 136) uS where the value of n is 0 to 15: A Mark is 210 uS A 0 Space is 760 uS A 1 Space is 896 uS A 2 Space is 1032 uS A 3 Space is 1168 uS A 4 Space is 1304 uS A 5 Space is 1440 uS A 6 Space is 1576 uS A 7 Space is 1712 uS A 8 Space is 1848 uS A 9 Space is 1984 uS A 10 Space is 2120 uS A 11 Space is 2256 uS A 12 Space is 2392 uS A 13 Space is 2528 uS A 14 Space is 2664 uS A 15 Space is 2800 uS The half frame Space is 13.8 mS, and the Trailer Space is 80.4 mS, (which is larger than an Adruino unsigned integer, and will be implemented with two delayMicroseconds () functions, which do not disable interrupts.) The xmp.timing(1) program was used to alter the Xfinity/Comcast XR2 remote timing values derived from the Arduino AnalysIR sketch, to industry standard values. The XR2 IR carrier frequency is 38 kHz. Sceptre television remote codes, for the Arduino IRLib2 library, (based on the rawSend sketch from the IRLib2 library.) The codes were derived from the AnalysIR sketch, with the IR receiver, (a TSOP38338 was used for the development,) in the middle of a large desk, about 2" from the remote LED. Due to the size of the IR code data, at least an Arduino Mega, (an Elegoo EL-CB-003 MEGA 2560 R3 Board ATmega2560 ATMEGA16U2 was used for the development,) will be required. (A Genuine Arduino UNO was tested, also, with a reduced number of buttons represented.) The TSOP38338 IR receiver output pin, (pin 1 = OUT on the TSOP38338 data sheet,) is connected to the Arduino input pin 2, (both Arduino MEGA and UNO.) The IR LED circuit is connected to the Arduino MEGA pin 9~. The IR LED circuit is connected to the Arduino UNO pin 3~. This sketch is intended to use the xr2USB0, or, sprawUSB0 raw terminal program as a command line input program from the computer terminal. The Sony remote protocol is based on a base timing value of 600 uS, and the timing values for a record are: 1) A Mark of 4 X 600 uS = 2.4 mS 2) Data Logical '0' a Space of 1 * 600 uS followed by a Mark of 1 * 600 uS 3) Data Logical '1' a Space of 1 * 600 uS followed by a Mark of 2 * 600 uS 4) A Record interval is always 75 * 600 uS = 45 mS 5) A Record is sent three times 6) A Space of at least 10 mS is sent at the end of a completion of the three Records being sent This simplifies the changing of the Sony timing values derived from the IRLib2 library, AnalysIR sketch, which can be rounded to the closest 600 uS value. The sony.timing(1) program was used to alter the Sceptre television remote timing values derived from the Arduino AnalysIR sketch, to industry standard values. The Sony (SIRC,) IR carrier frequency is 40 kHz. Dingsun Volume IR remote codes, for the Arduino IRLib2 library, (based on the rawSend sketch from the IRLib2 library.) The codes were derived from the AnalysIR sketch, with the IR receiver, (a TSOP38338 was used for the development,) in the middle of a large desk, about 2" from the remote LED. Due to the size of the IR code data, at least an Arduino Mega, (an Elegoo EL-CB-003 MEGA 2560 R3 Board ATmega2560 ATMEGA16U2 was used for the development,) will be required. (A Genuine Arduino UNO was tested, also, with a reduced number of buttons represented.) The TSOP38338 IR receiver output pin, (pin 1 = OUT on the TSOP38338 data sheet,) is connected to the Arduino input pin 2, (both Arduino MEGA and UNO.) The IR LED circuit is connected to the Arduino MEGA pin 9~. The IR LED circuit is connected to the Arduino UNO pin 3~. This sketch is intended to use the xr2USB0, or, sprawUSB0 raw terminal program as a command line input program from the computer terminal. The NEC remote protocol is based on a base timing value of 562.5 uS, and the timing values for a record are: 1) A Mark of 16 X 562.5 uS = 9 mS 2) A Space of 8 X 562.5 uS = 4.5 mS 3) Data Marks of 1 X 562.5 uS = 0.5625 mS 4) Data Spaces of 1 X 562.5 uS = 0.5625 mS 5) An EOR Space of 71 * 562.5 uS = 39.9375 mS between repeat codes The repeat code is: 1) A Mark of 16 X 562.5 uS = 9 mS 2) A Space of 4 X 562.5 uS = 2.25 mS 3) A Mark of 1 X 562.5 uS = 0.5625 mS This simplifies the changing of the NEC timing values derived from the IRLib2 library, AnalysIR sketch, which can be rounded to the closest 562.5 uS value. The nec.timing(1) program was used to alter the Dingsun remote timing values derived from the Arduino AnalysIR sketch, to industry standard values. The NEC IR carrier frequency is 38 kHz. The data structure is too large for an Arduino Uno, but note that the first and third unsigned integer array of each XR2 button's frame is identical for all buttons, reducing the XR2 data structure by about a factor of 2, and the first array of each Sony button's frame is sent three times. The data structure is too large for an Arduino Uno, but note that the first unsigned integer button's frame is repeated three times, reducing the Sony data structure by about a factor of 3. */ #include #include #include const uint16_t kIrLed = 4; // ESP8266 GPIO pin to use. Recommended: 4 (D2). IRsend irsend (kIrLed); // Set the GPIO to be used to sending the message. void setup () { irsend.begin (); Serial.begin (115200); delay (2000); while (!Serial); //delay for Leonardo Serial.print ("Ready: "); } // ################################################################### // Sceptre TV: // 'O' Sceptre TV remote Power button, Sony (SIRC,) protocol, 26 // fields, sent (at least 3,) times, uint16_t SonyButtonO[] = \ {2400, 600, 1200, 600, 600, 600, 1200, 600, 600, 600, 1200, 600, 600, 600, 600, 600, 1200, 600, 600, 600, 600, 600, 600, 600, 600, 25800, \ 2400, 600, 1200, 600, 600, 600, 1200, 600, 600, 600, 1200, 600, 600, 600, 600, 600, 1200, 600, 600, 600, 600, 600, 600, 600, 600, 25800, \ 2400, 600, 1200, 600, 600, 600, 1200, 600, 600, 600, 1200, 600, 600, 600, 600, 600, 1200, 600, 600, 600, 600, 600, 600, 600, 600 }; // '0' Sceptre TV remote 0 button, Sony (SIRC,) protocol, 26 // fields, sent (at least 3,) times, uint16_t SonyButton0[] = \ {2400, 600, 1200, 600, 600, 600, 600, 600, 1200, 600, 600, 600, 600, 600, 600, 600, 1200, 600, 600, 600, 600, 600, 600, 600, 600, 27000, \ 2400, 600, 1200, 600, 600, 600, 600, 600, 1200, 600, 600, 600, 600, 600, 600, 600, 1200, 600, 600, 600, 600, 600, 600, 600, 600, 27000, \ 2400, 600, 1200, 600, 600, 600, 600, 600, 1200, 600, 600, 600, 600, 600, 600, 600, 1200, 600, 600, 600, 600, 600, 600, 600, 600 }; // '1' Sceptre TV remote 1 button, Sony (SIRC,) protocol, 26 // fields, sent (at least 3,) times, uint16_t SonyButton1[] = \ {2400, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 1200, 600, 600, 600, 600, 600, 600, 600, 600, 28200, \ 2400, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 1200, 600, 600, 600, 600, 600, 600, 600, 600, 28200, \ 2400, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 1200, 600, 600, 600, 600, 600, 600, 600, 600 }; // '2' Sceptre TV remote 2 button, Sony (SIRC,) protocol, 26 // fields, sent (at least 3,) times, uint16_t SonyButton2[] = \ {2400, 600, 600, 600, 1200, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 1200, 600, 600, 600, 600, 600, 600, 600, 600, 27000, \ 2400, 600, 600, 600, 1200, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 1200, 600, 600, 600, 600, 600, 600, 600, 600, 27000, \ 2400, 600, 600, 600, 1200, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 1200, 600, 600, 600, 600, 600, 600, 600, 600 }; // '3' Sceptre TV remote 3 button, Sony (SIRC,) protocol, 26 // fields, sent (at least 3,) times, uint16_t SonyButton3[] = \ {2400, 600, 600, 600, 1200, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 1200, 600, 600, 600, 600, 600, 600, 600, 600, 27600, \ 2400, 600, 600, 600, 1200, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 1200, 600, 600, 600, 600, 600, 600, 600, 600, 27600, \ 2400, 600, 600, 600, 1200, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 1200, 600, 600, 600, 600, 600, 600, 600, 600 }; // '4' Sceptre TV remote 4 button, Sony (SIRC,) protocol, 26 // fields, sent (at least 3,) times, uint16_t SonyButton4[] = \ {2400, 600, 1200, 600, 1200, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 1200, 600, 600, 600, 600, 600, 600, 600, 600, 27000, \ 2400, 600, 1200, 600, 1200, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 1200, 600, 600, 600, 600, 600, 600, 600, 600, 27000, \ 2400, 600, 1200, 600, 1200, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 1200, 600, 600, 600, 600, 600, 600, 600, 600 }; // '5' Sceptre TV remote 5 button, Sony (SIRC,) protocol, 26 // fields, sent (at least 3,) times, uint16_t SonyButton5[] = \ {2400, 600, 600, 600, 600, 600, 1200, 600, 600, 600, 600, 600, 600, 600, 600, 600, 1200, 600, 600, 600, 600, 600, 600, 600, 600, 27600, \ 2400, 600, 600, 600, 600, 600, 1200, 600, 600, 600, 600, 600, 600, 600, 600, 600, 1200, 600, 600, 600, 600, 600, 600, 600, 600, 27600, \ 2400, 600, 600, 600, 600, 600, 1200, 600, 600, 600, 600, 600, 600, 600, 600, 600, 1200, 600, 600, 600, 600, 600, 600, 600, 600 }; // '6' Sceptre TV remote 6 button, Sony (SIRC,) protocol, 26 // fields, sent (at least 3,) times, uint16_t SonyButton6[] = \ {2400, 600, 1200, 600, 600, 600, 1200, 600, 600, 600, 600, 600, 600, 600, 600, 600, 1200, 600, 600, 600, 600, 600, 600, 600, 600, 26400, \ 2400, 600, 1200, 600, 600, 600, 1200, 600, 600, 600, 600, 600, 600, 600, 600, 600, 1200, 600, 600, 600, 600, 600, 600, 600, 600, 26400, \ 2400, 600, 1200, 600, 600, 600, 1200, 600, 600, 600, 600, 600, 600, 600, 600, 600, 1200, 600, 600, 600, 600, 600, 600, 600, 600 }; // '7' Sceptre TV remote 7 button, Sony (SIRC,) protocol, 26 // fields, sent (at least 3,) times, uint16_t SonyButton7[] = \ {2400, 600, 600, 600, 1200, 600, 1200, 600, 600, 600, 600, 600, 600, 600, 600, 600, 1200, 600, 600, 600, 600, 600, 600, 600, 600, 27000, \ 2400, 600, 600, 600, 1200, 600, 1200, 600, 600, 600, 600, 600, 600, 600, 600, 600, 1200, 600, 600, 600, 600, 600, 600, 600, 600, 27000, \ 2400, 600, 600, 600, 1200, 600, 1200, 600, 600, 600, 600, 600, 600, 600, 600, 600, 1200, 600, 600, 600, 600, 600, 600, 600, 600 }; // '8' Sceptre TV remote 8 button, Sony (SIRC,) protocol, 26 // fields, sent (at least 3,) times, uint16_t SonyButton8[] = \ {2400, 600, 1200, 600, 1200, 600, 1200, 600, 600, 600, 600, 600, 600, 600, 600, 600, 1200, 600, 600, 600, 600, 600, 600, 600, 600, 26400, \ 2400, 600, 1200, 600, 1200, 600, 1200, 600, 600, 600, 600, 600, 600, 600, 600, 600, 1200, 600, 600, 600, 600, 600, 600, 600, 600, 26400, \ 2400, 600, 1200, 600, 1200, 600, 1200, 600, 600, 600, 600, 600, 600, 600, 600, 600, 1200, 600, 600, 600, 600, 600, 600, 600, 600 }; // '9' Sceptre TV remote 9 button, Sony (SIRC,) protocol, 26 // fields, sent (at least 3,) times, uint16_t SonyButton9[] = \ {2400, 600, 600, 600, 600, 600, 600, 600, 1200, 600, 600, 600, 600, 600, 600, 600, 1200, 600, 600, 600, 600, 600, 600, 600, 600, 27600, \ 2400, 600, 600, 600, 600, 600, 600, 600, 1200, 600, 600, 600, 600, 600, 600, 600, 1200, 600, 600, 600, 600, 600, 600, 600, 600, 27600, \ 2400, 600, 600, 600, 600, 600, 600, 600, 1200, 600, 600, 600, 600, 600, 600, 600, 1200, 600, 600, 600, 600, 600, 600, 600, 600 }; // 'c' Sceptre TV remote CH- button, Sony (SIRC,) protocol, 26 // fields, sent (at least 3,) times, uint16_t SonyButtonChDown[] = \ {2400, 600, 1200, 600, 600, 600, 600, 600, 600, 600, 1200, 600, 600, 600, 600, 600, 1200, 600, 600, 600, 600, 600, 600, 600, 600, 27000, \ 2400, 600, 1200, 600, 600, 600, 600, 600, 600, 600, 1200, 600, 600, 600, 600, 600, 1200, 600, 600, 600, 600, 600, 600, 600, 600, 27000, \ 2400, 600, 1200, 600, 600, 600, 600, 600, 600, 600, 1200, 600, 600, 600, 600, 600, 1200, 600, 600, 600, 600, 600, 600, 600, 600 }; // 'C' Sceptre TV remote CH+ button, Sony (SIRC,) protocol, 26 // fields, sent (at least 3,) times, uint16_t SonyButtonChUp[] = \ {2400, 600, 600, 600, 600, 600, 600, 600, 600, 600, 1200, 600, 600, 600, 600, 600, 1200, 600, 600, 600, 600, 600, 600, 600, 600, 27600, \ 2400, 600, 600, 600, 600, 600, 600, 600, 600, 600, 1200, 600, 600, 600, 600, 600, 1200, 600, 600, 600, 600, 600, 600, 600, 600, 27600, \ 2400, 600, 600, 600, 600, 600, 600, 600, 600, 600, 1200, 600, 600, 600, 600, 600, 1200, 600, 600, 600, 600, 600, 600, 600, 600 }; // 'd' Sceptre TV remote Down button, Sony (SIRC,) protocol, 26 // fields, sent (at least 3,) times, uint16_t SonyButtonDown[] = \ {2400, 600, 1200, 600, 600, 600, 1200, 600, 600, 600, 1200, 600, 1200, 600, 1200, 600, 1200, 600, 600, 600, 600, 600, 600, 600, 600, 25200, \ 2400, 600, 1200, 600, 600, 600, 1200, 600, 600, 600, 1200, 600, 1200, 600, 1200, 600, 1200, 600, 600, 600, 600, 600, 600, 600, 600, 25200, \ 2400, 600, 1200, 600, 600, 600, 1200, 600, 600, 600, 1200, 600, 1200, 600, 1200, 600, 1200, 600, 600, 600, 600, 600, 600, 600, 600 }; // 'e' Sceptre TV remote ENTER button, Sony (SIRC,) protocol, 26 // fields, sent (at least 3,) times, uint16_t SonyButtonEnter[] = \ {2400, 600, 1200, 600, 1200, 600, 600, 600, 1200, 600, 600, 600, 600, 600, 600, 600, 1200, 600, 600, 600, 600, 600, 600, 600, 600, 26400, \ 2400, 600, 1200, 600, 1200, 600, 600, 600, 1200, 600, 600, 600, 600, 600, 600, 600, 1200, 600, 600, 600, 600, 600, 600, 600, 600, 26400, \ 2400, 600, 1200, 600, 1200, 600, 600, 600, 1200, 600, 600, 600, 600, 600, 600, 600, 1200, 600, 600, 600, 600, 600, 600, 600, 600 }; // 'E' Sceptre TV remote Exit button, Sony (SIRC,) protocol, 26 // fields, sent (at least 3,) times, uint16_t SonyButtonExit[] = \ {2400, 600, 600, 600, 1200, 600, 1200, 600, 600, 600, 1200, 600, 600, 600, 600, 600, 1200, 600, 600, 600, 600, 600, 600, 600, 600, 26400, \ 2400, 600, 600, 600, 1200, 600, 1200, 600, 600, 600, 1200, 600, 600, 600, 600, 600, 1200, 600, 600, 600, 600, 600, 600, 600, 600, 26400, \ 2400, 600, 600, 600, 1200, 600, 1200, 600, 600, 600, 1200, 600, 600, 600, 600, 600, 1200, 600, 600, 600, 600, 600, 600, 600, 600 }; // 'I' Sceptre TV remote Guide button, Sony (SIRC,) protocol, 26 // fields, sent (at least 3,) times, uint16_t SonyButtonGuide[] = \ {2400, 600, 1200, 600, 600, 600, 1200, 600, 600, 600, 600, 600, 1200, 600, 1200, 600, 1200, 600, 600, 600, 600, 600, 600, 600, 600, 25800, \ 2400, 600, 1200, 600, 600, 600, 1200, 600, 600, 600, 600, 600, 1200, 600, 1200, 600, 1200, 600, 600, 600, 600, 600, 600, 600, 600, 25800, \ 2400, 600, 1200, 600, 600, 600, 1200, 600, 600, 600, 600, 600, 1200, 600, 1200, 600, 1200, 600, 600, 600, 600, 600, 600, 600, 600 }; // 'l' Sceptre TV remote Left button, Sony (SIRC,) protocol, 26 // fields, sent (at least 3,) times, uint16_t SonyButtonLeft[] = \ {2400, 600, 600, 600, 600, 600, 1200, 600, 600, 600, 1200, 600, 1200, 600, 600, 600, 1200, 600, 600, 600, 600, 600, 600, 600, 600, 26400, \ 2400, 600, 600, 600, 600, 600, 1200, 600, 600, 600, 1200, 600, 1200, 600, 600, 600, 1200, 600, 600, 600, 600, 600, 600, 600, 600, 26400, \ 2400, 600, 600, 600, 600, 600, 1200, 600, 600, 600, 1200, 600, 1200, 600, 600, 600, 1200, 600, 600, 600, 600, 600, 600, 600, 600 }; // 'M' Sceptre TV remote Menu button, Sony (SIRC,) protocol, 26 // fields, sent (at least 3,) times, uint16_t SonyButtonMenu[] = \ {2400, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 1200, 600, 1200, 600, 1200, 600, 600, 600, 600, 600, 600, 600, 600, 27000, \ 2400, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 1200, 600, 1200, 600, 1200, 600, 600, 600, 600, 600, 600, 600, 600, 27000, \ 2400, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 1200, 600, 1200, 600, 1200, 600, 600, 600, 600, 600, 600, 600, 600 }; // 'r' Sceptre TV remote Right button, Sony (SIRC,) protocol, 26 // fields, sent (at least 3,) times, uint16_t SonyButtonRight[] = \ {2400, 600, 1200, 600, 1200, 600, 600, 600, 600, 600, 1200, 600, 1200, 600, 600, 600, 1200, 600, 600, 600, 600, 600, 600, 600, 600, 25800, \ 2400, 600, 1200, 600, 1200, 600, 600, 600, 600, 600, 1200, 600, 1200, 600, 600, 600, 1200, 600, 600, 600, 600, 600, 600, 600, 600, 25800, \ 2400, 600, 1200, 600, 1200, 600, 600, 600, 600, 600, 1200, 600, 1200, 600, 600, 600, 1200, 600, 600, 600, 600, 600, 600, 600, 600 }; // 's' Sceptre TV remote Source button, Sony (SIRC,) protocol, 26 // fields, sent (at least 3,) times, uint16_t SonyButtonSource[] = \ {2400, 600, 1200, 600, 600, 600, 1200, 600, 600, 600, 600, 600, 1200, 600, 600, 600, 1200, 600, 600, 600, 600, 600, 600, 600, 600, 26400, \ 2400, 600, 1200, 600, 600, 600, 1200, 600, 600, 600, 600, 600, 1200, 600, 600, 600, 1200, 600, 600, 600, 600, 600, 600, 600, 600, 26400, \ 2400, 600, 1200, 600, 600, 600, 1200, 600, 600, 600, 600, 600, 1200, 600, 600, 600, 1200, 600, 600, 600, 600, 600, 600, 600, 600 }; // 'u' Sceptre TV remote Up button, Sony (SIRC,) protocol, 26 // fields, sent (at least 3,) times, uint16_t SonyButtonUp[] = \ {2400, 600, 600, 600, 600, 600, 1200, 600, 600, 600, 1200, 600, 1200, 600, 1200, 600, 1200, 600, 600, 600, 600, 600, 600, 600, 600, 25800, \ 2400, 600, 600, 600, 600, 600, 1200, 600, 600, 600, 1200, 600, 1200, 600, 1200, 600, 1200, 600, 600, 600, 600, 600, 600, 600, 600, 25800, \ 2400, 600, 600, 600, 600, 600, 1200, 600, 600, 600, 1200, 600, 1200, 600, 1200, 600, 1200, 600, 600, 600, 600, 600, 600, 600, 600 }; // 'v' Sceptre TV remote VOL- button, Sony (SIRC,) protocol, 26 // fields, sent (at least 3,) times, uint16_t SonyButtonVolDown[] = \ {2400, 600, 1200, 600, 1200, 600, 600, 600, 600, 600, 1200, 600, 600, 600, 600, 600, 1200, 600, 600, 600, 600, 600, 600, 600, 600, 26400, \ 2400, 600, 1200, 600, 1200, 600, 600, 600, 600, 600, 1200, 600, 600, 600, 600, 600, 1200, 600, 600, 600, 600, 600, 600, 600, 600, 26400, \ 2400, 600, 1200, 600, 1200, 600, 600, 600, 600, 600, 1200, 600, 600, 600, 600, 600, 1200, 600, 600, 600, 600, 600, 600, 600, 600 }; // 'V' Sceptre TV remote VOL+ button, Sony (SIRC,) protocol, 26 // fields, sent (at least 3,) times, uint16_t SonyButtonVolUp[] = \ {2400, 600, 600, 600, 1200, 600, 600, 600, 600, 600, 1200, 600, 600, 600, 600, 600, 1200, 600, 600, 600, 600, 600, 600, 600, 600, 27000, \ 2400, 600, 600, 600, 1200, 600, 600, 600, 600, 600, 1200, 600, 600, 600, 600, 600, 1200, 600, 600, 600, 600, 600, 600, 600, 600, 27000, \ 2400, 600, 600, 600, 1200, 600, 600, 600, 600, 600, 1200, 600, 600, 600, 600, 600, 1200, 600, 600, 600, 600, 600, 600, 600, 600 }; // ################################################################### // Dingsun Volume: // '+' Dingsun IR Remote Volume Control, remote Volume Up button, NEC // protocol, 75 fields, uint16_t NecVolumeUp[] = \ {9000, 4500, 563, 563, 563, 563, 563, 563, 563, 563, 563, 563, 563, 563, 563, 563, 563, 1688, 563, 1688, 563, 1688, 563, 1688, 563, \ 1688, 563, 1688, 563, 1688, 563, 1688, 563, 563, 563, 563, 563, 1688, 563, 563, 563, 563, 563, 563, 563, 563, 563, 563, 563, 563, \ 563, 1688, 563, 563, 563, 1688, 563, 1688, 563, 1688, 563, 1688, 563, 1688, 563, 1688, 563, 39938, 9000, 2250, 563, 31500, 9000, 2250, 563 }; // '-' Dingsun IR Remote Volume Control, remote Volume Down button, // NEC protocol, 75 fields, uint16_t NecVolumeDown[] = \ {9000, 4500, 563, 563, 563, 563, 563, 563, 563, 563, 563, 563, 563, 563, 563, 563, 563, 1688, 563, 1688, 563, 1688, 563, 1688, 563, \ 1688, 563, 1688, 563, 1688, 563, 1688, 563, 563, 563, 563, 563, 563, 563, 563, 563, 1688, 563, 563, 563, 563, 563, 563, 563, 563, \ 563, 1688, 563, 1688, 563, 1688, 563, 563, 563, 1688, 563, 1688, 563, 1688, 563, 1688, 563, 39938, 9000, 2250, 563, 31500, 9000, 2250, 563 }; // 'Mute' Dingsun IR Remote Volume Control, remote Mute button, // NEC protocol 75 fields, uint16_t NecMute[] = \ {9000, 4500, 563, 563, 563, 563, 563, 563, 563, 563, 563, 563, 563, 563, 563, 563, 563, 1688, 563, 1688, 563, 1688, 563, 1688, 563, \ 1688, 563, 1688, 563, 1688, 563, 1688, 563, 563, 563, 563, 563, 1688, 563, 563, 563, 1688, 563, 1688, 563, 563, 563, 563, 563, 563, \ 563, 1688, 563, 563, 563, 1688, 563, 563, 563, 563, 563, 1688, 563, 1688, 563, 1688, 563, 39938, 9000, 2250, 563, 31500, 9000, 2250, 563 }; // ################################################################### // Xfinity XR2: // '0' Xfinity XR2 remote 0 button, 71 fields: uint16_t Xr2Button0[] = \ {210, 896, 210, 1712, 210, 760, 210, 2800, 210, 1304, 210, 1304, 210, 1168, 210, 2664, 210, 13800, 210, 896, 210, 2800, 210, 760, 210, 760, 210, 760, 210, 760, 210, 760, 210, 760, 210, 13800, 210, 896, 210, 1712, 210, 760, 210, 2800, 210, 1304, 210, 1304, 210, 1168, 210, 2664, 210, 13800, 210, 896, 210, 1712, 210, 1848, 210, 760, 210, 760, 210, 760, 210, 760, 210, 760, 210 }; // '1' Xfinity XR2 remote 1 button, 71 fields: uint16_t Xr2Button1[] = \ {210, 896, 210, 1712, 210, 760, 210, 2800, 210, 1304, 210, 1304, 210, 1168, 210, 2664, 210, 13800, 210, 896, 210, 2664, 210, 760, 210, 760, 210, 760, 210, 896, 210, 760, 210, 760, 210, 13800, 210, 896, 210, 1712, 210, 760, 210, 2800, 210, 1304, 210, 1304, 210, 1168, 210, 2664, 210, 13800, 210, 896, 210, 1576, 210, 1848, 210, 760, 210, 760, 210, 896, 210, 760, 210, 760, 210 }; // '2' Xfinity XR2 remote 2 button, 71 fields: uint16_t Xr2Button2[] = \ {210, 896, 210, 1712, 210, 760, 210, 2800, 210, 1304, 210, 1304, 210, 1168, 210, 2664, 210, 13800, 210, 896, 210, 2528, 210, 760, 210, 760, 210, 760, 210, 1032, 210, 760, 210, 760, 210, 13800, 210, 896, 210, 1712, 210, 760, 210, 2800, 210, 1304, 210, 1304, 210, 1168, 210, 2664, 210, 13800, 210, 896, 210, 1440, 210, 1848, 210, 760, 210, 760, 210, 1032, 210, 760, 210, 760, 210 }; // '3' Xfinity XR2 remote 3 button, 71 fields: uint16_t Xr2Button3[] = \ {210, 896, 210, 1712, 210, 760, 210, 2800, 210, 1304, 210, 1304, 210, 1168, 210, 2664, 210, 13800, 210, 896, 210, 2392, 210, 760, 210, 760, 210, 760, 210, 1168, 210, 760, 210, 760, 210, 13800, 210, 896, 210, 1712, 210, 760, 210, 2800, 210, 1304, 210, 1304, 210, 1168, 210, 2664, 210, 13800, 210, 896, 210, 1304, 210, 1848, 210, 760, 210, 760, 210, 1168, 210, 760, 210, 760, 210 }; // '4' Xfinity XR2 remote 4 button, 71 fields: uint16_t Xr2Button4[] = \ {210, 896, 210, 1712, 210, 760, 210, 2800, 210, 1304, 210, 1304, 210, 1168, 210, 2664, 210, 13800, 210, 896, 210, 2256, 210, 760, 210, 760, 210, 760, 210, 1304, 210, 760, 210, 760, 210, 13800, 210, 896, 210, 1712, 210, 760, 210, 2800, 210, 1304, 210, 1304, 210, 1168, 210, 2664, 210, 13800, 210, 896, 210, 1168, 210, 1848, 210, 760, 210, 760, 210, 1304, 210, 760, 210, 760, 210 }; // '5' Xfinity XR2 remote 5 button, 71 fields: uint16_t Xr2Button5[] = \ {210, 896, 210, 1712, 210, 760, 210, 2800, 210, 1304, 210, 1304, 210, 1168, 210, 2664, 210, 13800, 210, 896, 210, 2120, 210, 760, 210, 760, 210, 760, 210, 1440, 210, 760, 210, 760, 210, 13800, 210, 896, 210, 1712, 210, 760, 210, 2800, 210, 1304, 210, 1304, 210, 1168, 210, 2664, 210, 13800, 210, 896, 210, 1032, 210, 1848, 210, 760, 210, 760, 210, 1440, 210, 760, 210, 760, 210 }; // '6' Xfinity XR2 remote 6 button, 71 fields: uint16_t Xr2Button6[] = \ {210, 896, 210, 1712, 210, 760, 210, 2800, 210, 1304, 210, 1304, 210, 1168, 210, 2664, 210, 13800, 210, 896, 210, 1984, 210, 760, 210, 760, 210, 760, 210, 1576, 210, 760, 210, 760, 210, 13800, 210, 896, 210, 1712, 210, 760, 210, 2800, 210, 1304, 210, 1304, 210, 1168, 210, 2664, 210, 13800, 210, 896, 210, 896, 210, 1848, 210, 760, 210, 760, 210, 1576, 210, 760, 210, 760, 210 }; // '7' Xfinity XR2 remote 7 button, 71 fields: uint16_t Xr2Button7[] = \ {210, 896, 210, 1712, 210, 760, 210, 2800, 210, 1304, 210, 1304, 210, 1168, 210, 2664, 210, 13800, 210, 896, 210, 1848, 210, 760, 210, 760, 210, 760, 210, 1712, 210, 760, 210, 760, 210, 13800, 210, 896, 210, 1712, 210, 760, 210, 2800, 210, 1304, 210, 1304, 210, 1168, 210, 2664, 210, 13800, 210, 896, 210, 760, 210, 1848, 210, 760, 210, 760, 210, 1712, 210, 760, 210, 760, 210 }; // '8' Xfinity XR2 remote 8 button, 71 fields: uint16_t Xr2Button8[] = \ {210, 896, 210, 1712, 210, 760, 210, 2800, 210, 1304, 210, 1304, 210, 1168, 210, 2664, 210, 13800, 210, 896, 210, 1712, 210, 760, 210, 760, 210, 760, 210, 1848, 210, 760, 210, 760, 210, 13800, 210, 896, 210, 1712, 210, 760, 210, 2800, 210, 1304, 210, 1304, 210, 1168, 210, 2664, 210, 13800, 210, 896, 210, 2800, 210, 1848, 210, 760, 210, 760, 210, 1848, 210, 760, 210, 760, 210 }; // '9' Xfinity XR2 remote 9 button, 71 fields: uint16_t Xr2Button9[] = \ {210, 896, 210, 1712, 210, 760, 210, 2800, 210, 1304, 210, 1304, 210, 1168, 210, 2664, 210, 13800, 210, 896, 210, 1576, 210, 760, 210, 760, 210, 760, 210, 1984, 210, 760, 210, 760, 210, 13800, 210, 896, 210, 1712, 210, 760, 210, 2800, 210, 1304, 210, 1304, 210, 1168, 210, 2664, 210, 13800, 210, 896, 210, 2664, 210, 1848, 210, 760, 210, 760, 210, 1984, 210, 760, 210, 760, 210 }; // 'C' Xfinity XR2 remote CH UP button, 71 fields: uint16_t Xr2ButtonC[] = \ {210, 896, 210, 1712, 210, 760, 210, 2800, 210, 1304, 210, 1304, 210, 1168, 210, 2664, 210, 13800, 210, 896, 210, 1032, 210, 760, 210, 760, 210, 760, 210, 2528, 210, 760, 210, 760, 210, 13800, 210, 896, 210, 1712, 210, 760, 210, 2800, 210, 1304, 210, 1304, 210, 1168, 210, 2664, 210, 13800, 210, 896, 210, 2120, 210, 1848, 210, 760, 210, 760, 210, 2528, 210, 760, 210, 760, 210 }; // 'c' Xfinity XR2 remote CH DOWN button, 71 fields: uint16_t Xr2Buttonc[] = \ {210, 896, 210, 1712, 210, 760, 210, 2800, 210, 1304, 210, 1304, 210, 1168, 210, 2664, 210, 13800, 210, 896, 210, 896, 210, 760, 210, 760, 210, 760, 210, 2664, 210, 760, 210, 760, 210, 13800, 210, 896, 210, 1712, 210, 760, 210, 2800, 210, 1304, 210, 1304, 210, 1168, 210, 2664, 210, 13800, 210, 896, 210, 1984, 210, 1848, 210, 760, 210, 760, 210, 2664, 210, 760, 210, 760, 210 }; // 'd' Xfinity XR2 remote \/ button, 71 fields: uint16_t Xr2Buttond[] = \ {210, 896, 210, 1712, 210, 760, 210, 2800, 210, 1304, 210, 1304, 210, 1168, 210, 2664, 210, 13800, 210, 896, 210, 2256, 210, 760, 210, 760, 210, 1032, 210, 1032, 210, 760, 210, 760, 210, 13800, 210, 896, 210, 1712, 210, 760, 210, 2800, 210, 1304, 210, 1304, 210, 1168, 210, 2664, 210, 13800, 210, 896, 210, 1168, 210, 1848, 210, 760, 210, 1032, 210, 1032, 210, 760, 210, 760, 210 }; // 'E' Xfinity XR2 remote Exit button, 71 fields: uint16_t Xr2ButtonE[] = \ {210, 896, 210, 1712, 210, 760, 210, 2800, 210, 1304, 210, 1304, 210, 1168, 210, 2664, 210, 13800, 210, 896, 210, 1168, 210, 760, 210, 760, 210, 1032, 210, 2120, 210, 760, 210, 760, 210, 13800, 210, 896, 210, 1712, 210, 760, 210, 2800, 210, 1304, 210, 1304, 210, 1168, 210, 2664, 210, 13800, 210, 896, 210, 2256, 210, 1848, 210, 760, 210, 1032, 210, 2120, 210, 760, 210, 760, 210 }; // 'G' Xfinity XR2 remote Guide button, 71 fields: uint16_t Xr2ButtonG[] = \ {210, 896, 210, 1712, 210, 760, 210, 2800, 210, 1304, 210, 1304, 210, 1168, 210, 2664, 210, 13800, 210, 896, 210, 1576, 210, 760, 210, 760, 210, 1032, 210, 1712, 210, 760, 210, 760, 210, 13800, 210, 896, 210, 1712, 210, 760, 210, 2800, 210, 1304, 210, 1304, 210, 1168, 210, 2664, 210, 13800, 210, 896, 210, 896, 210, 760, 210, 760, 210, 2664, 210, 760, 210, 760, 210, 760, 210 }; // 'I' Xfinity XR2 remote Info button, 71 fields: uint16_t Xr2ButtonI[] = \ {210, 896, 210, 1712, 210, 760, 210, 2800, 210, 1304, 210, 1304, 210, 1168, 210, 2664, 210, 13800, 210, 896, 210, 1712, 210, 760, 210, 760, 210, 1032, 210, 1576, 210, 760, 210, 760, 210, 13800, 210, 896, 210, 1712, 210, 760, 210, 2800, 210, 1304, 210, 1304, 210, 1168, 210, 2664, 210, 13800, 210, 896, 210, 2800, 210, 1848, 210, 760, 210, 1032, 210, 1576, 210, 760, 210, 760, 210 }; // 'k' Xfinity XR2 remote OK button, 71 fields: uint16_t Xr2Buttonk[] = \ {210, 896, 210, 1712, 210, 760, 210, 2800, 210, 1304, 210, 1304, 210, 1168, 210, 2664, 210, 13800, 210, 896, 210, 1848, 210, 760, 210, 760, 210, 1032, 210, 1440, 210, 760, 210, 760, 210, 13800, 210, 896, 210, 1712, 210, 760, 210, 2800, 210, 1304, 210, 1304, 210, 1168, 210, 2664, 210, 13800, 210, 896, 210, 760, 210, 1848, 210, 760, 210, 1032, 210, 1440, 210, 760, 210, 760, 210 }; // 'L' Xfinity XR2 remote Last button, 71 fields: uint16_t Xr2ButtonL[] = \ {210, 896, 210, 1712, 210, 760, 210, 2800, 210, 1304, 210, 1304, 210, 1168, 210, 2664, 210, 13800, 210, 896, 210, 1984, 210, 760, 210, 760, 210, 1440, 210, 896, 210, 760, 210, 760, 210, 13800, 210, 896, 210, 1712, 210, 760, 210, 2800, 210, 1304, 210, 1304, 210, 1168, 210, 2664, 210, 13800, 210, 896, 210, 896, 210, 1848, 210, 760, 210, 1440, 210, 896, 210, 760, 210, 760, 210 }; // 'l' Xfinity XR2 remote < button, 71 fields: uint16_t Xr2Buttonl[] = \ {210, 896, 210, 1712, 210, 760, 210, 2800, 210, 1304, 210, 1304, 210, 1168, 210, 2664, 210, 13800, 210, 896, 210, 2120, 210, 760, 210, 760, 210, 1032, 210, 1168, 210, 760, 210, 760, 210, 13800, 210, 896, 210, 1712, 210, 760, 210, 2800, 210, 1304, 210, 1304, 210, 1168, 210, 2664, 210, 13800, 210, 896, 210, 1032, 210, 1848, 210, 760, 210, 1032, 210, 1168, 210, 760, 210, 760, 210 }; // 'P' Xfinity XR2 remote Pg /\ button, 71 fields: uint16_t Xr2ButtonP[] = \ {210, 896, 210, 1712, 210, 760, 210, 2800, 210, 1304, 210, 1304, 210, 1168, 210, 2664, 210, 13800, 210, 896, 210, 1440, 210, 760, 210, 760, 210, 1032, 210, 1848, 210, 760, 210, 760, 210, 13800, 210, 896, 210, 1712, 210, 760, 210, 2800, 210, 1304, 210, 1304, 210, 1168, 210, 2664, 210, 13800, 210, 896, 210, 2528, 210, 1848, 210, 760, 210, 1032, 210, 1848, 210, 760, 210, 760, 210 }; // 'p' Xfinity XR2 remote Pg \/ button, 71 fields: uint16_t Xr2Buttonp[] = \ {210, 896, 210, 1712, 210, 760, 210, 2800, 210, 1304, 210, 1304, 210, 1168, 210, 2664, 210, 13800, 210, 896, 210, 1304, 210, 760, 210, 760, 210, 1032, 210, 1984, 210, 760, 210, 760, 210, 13800, 210, 896, 210, 1712, 210, 760, 210, 2800, 210, 1304, 210, 1304, 210, 1168, 210, 2664, 210, 13800, 210, 896, 210, 2392, 210, 1848, 210, 760, 210, 1032, 210, 1984, 210, 760, 210, 760, 210 }; // 'r' Xfinity XR2 remote > button, 71 fields: uint16_t Xr2Buttonr[] = \ {210, 896, 210, 1712, 210, 760, 210, 2800, 210, 1304, 210, 1304, 210, 1168, 210, 2664, 210, 13800, 210, 896, 210, 1984, 210, 760, 210, 760, 210, 1032, 210, 1304, 210, 760, 210, 760, 210, 13800, 210, 896, 210, 1712, 210, 760, 210, 2800, 210, 1304, 210, 1304, 210, 1168, 210, 2664, 210, 13800, 210, 896, 210, 896, 210, 1848, 210, 760, 210, 1032, 210, 1304, 210, 760, 210, 760, 210 }; // 'u' Xfinity XR2 remote /\ button, 71 fields: uint16_t Xr2Buttonu[] = \ {210, 896, 210, 1712, 210, 760, 210, 2800, 210, 1304, 210, 1304, 210, 1168, 210, 2664, 210, 13800, 210, 896, 210, 2392, 210, 760, 210, 760, 210, 1032, 210, 896, 210, 760, 210, 760, 210, 13800, 210, 896, 210, 1712, 210, 760, 210, 2800, 210, 1304, 210, 1304, 210, 1168, 210, 2664, 210, 13800, 210, 896, 210, 1304, 210, 1848, 210, 760, 210, 1032, 210, 896, 210, 760, 210, 760, 210 }; // ################################################################### // Xr2 remote vs. terminal keyboard key mapping: char Xr2Help[] = \ "\n\n" "Xr2 Remote Key Mapping:\n" "Remote Single Character\n" "Button Keyboard Key\n" "\n" "Power button, (On/Off) 'O', 'o', '.'\n" "0 button '0'\n" "1 button '1'\n" "2 button '2'\n" "3 button '3'\n" "4 button '4'\n" "5 button '5'\n" "6 button '6'\n" "7 button '7'\n" "8 button '8'\n" "9 button '9'\n" "CH UP button 'C', Insert, Ins\n" "CH DOWN button 'c', Delete, Del\n" "Down Arrow button 'D', Down Arrow\n" "Exit button 'E', 'e', End\n" "Guide button 'G', 'g', Home\n" "(This Help) 'H', 'h', '?'\n" "Info button 'I', 'i', '/'\n" "OK button 'k', 'K', Enter\n" "Last button 'l', '*'\n" "Left Arrow button 'L', Left Arrow\n" "Mute button, (Toggle) 'M', 'm'\n" "Pg Up button 'P', Page Up, Pg Up\n" "Pg Down button 'p', Page Down, Pg Dn\n" "(Quit) 'Q', 'q'\n" "Right Arrow button 'R', Right Arrow\n" "Sceptre TV 'T'\n" "Xfinity TV 't'\n" "Up Arrow button 'U', Up Arrow\n" "Volume Up button 'V', '+'\n" "Volume Down button 'v', '-'\n" "\n"; // Sceptre remote vs. terminal keyboard key mapping: char SceptreHelp[] = \ "\n\n" "Sceptre Television Remote Key Mapping:\n" "Remote Single Character\n" "Button Keyboard Key\n" "\n" "Power button, (On/Off) 'O', 'o', '.'\n" "0 button '0'\n" "1 button '1'\n" "2 button '2'\n" "3 button '3'\n" "4 button '4'\n" "5 button '5'\n" "6 button '6'\n" "7 button '7'\n" "8 button '8'\n" "9 button '9'\n" "CH+ button 'C', Insert, Ins\n" "CH- button 'c', Delete, Del\n" "Down Arrow button 'D', Down Arrow\n" "Exit button 'E', 'e', End\n" "Menu button 'G', 'g', Home\n" "(This Help) 'H', 'h', '?'\n" "Guide button 'I', 'i', '/'\n" "Enter button 'k', 'K', Enter\n" "Left Arrow button 'L', Left Arrow\n" "Mute button, (Toggle) 'M', 'm'\n" "(Quit) 'Q', 'q'\n" "Right Arrow button 'R', Right Arrow\n" "Source button 'S', 's'\n" "Sceptre TV 'T'\n" "Xfinity TV 't'\n" "Up Arrow button 'U', Up Arrow\n" "VOL+ button 'V'\n" "VOL- button 'v',\n" "Volume Up button '+'\n" "Volume Down button '-'\n" "\n"; char device = '0'; /* '0' = Xr2 remote, '1' = Sceptre remote */ void loop () { char ch; // Input character from the serial line int sz, // Size of unsigned int array to be sent button_error = 0, // No such button error, no error = 0, error = 1 xmp = 0, // xmp button, 0 = no, 1 = yes nec = 0, // nec button, 0 = no, 1 = yes sony = 0; // sony button, 0 = no, 1 = yes uint16_t *ary; // Reference to unsigned int array to be sent if (Serial.available ()) { ch = Serial.read (); button_error = 0; // Reset the no such button error xmp = 0; // reset the xmp button, 0 = no, 1 = yes nec = 0; // reset the nec button, 0 = no, 1 = yes sony = 0; // reset the sony button, 0 = no, 1 = yes switch (device) /* '0' = Xr2 remote, '1' = Sceptre remote */ { case '1': /* '0' = Xr2 remote, '1' = Sceptre remote */ switch (ch) { case 'O': case 'o': case '.': ary = SonyButtonO; sz = sizeof (SonyButtonO); sony = 1; // set the sony button, 0 = no, 1 = yes break; case '0': ary = SonyButton0; sz = sizeof (SonyButton0); sony = 1; // set the sony button, 0 = no, 1 = yes break; case '1': ary = SonyButton1; sz = sizeof (SonyButton1); sony = 1; // set the sony button, 0 = no, 1 = yes break; case '2': ary = SonyButton2; sz = sizeof (SonyButton2); sony = 1; // set the sony button, 0 = no, 1 = yes break; case '3': ary = SonyButton3; sz = sizeof (SonyButton3); sony = 1; // set the sony button, 0 = no, 1 = yes break; case '4': ary = SonyButton4; sz = sizeof (SonyButton4); sony = 1; // set the sony button, 0 = no, 1 = yes break; case '5': ary = SonyButton5; sz = sizeof (SonyButton5); sony = 1; // set the sony button, 0 = no, 1 = yes break; case '6': ary = SonyButton6; sz = sizeof (SonyButton6); sony = 1; // set the sony button, 0 = no, 1 = yes break; case '7': ary = SonyButton7; sz = sizeof (SonyButton7); sony = 1; // set the sony button, 0 = no, 1 = yes break; case '8': ary = SonyButton8; sz = sizeof (SonyButton8); sony = 1; // set the sony button, 0 = no, 1 = yes break; case '9': ary = SonyButton9; sz = sizeof (SonyButton9); sony = 1; // set the sony button, 0 = no, 1 = yes break; case 'C': ary = SonyButtonChUp; sz = sizeof (SonyButtonChUp); sony = 1; // set the sony button, 0 = no, 1 = yes break; case 'c': ary = SonyButtonChDown; sz = sizeof (SonyButtonChDown); sony = 1; // set the sony button, 0 = no, 1 = yes break; case 'D': ary = SonyButtonDown; sz = sizeof (SonyButtonDown); sony = 1; // set the sony button, 0 = no, 1 = yes break; case 'E': case 'e': ary = SonyButtonExit; sz = sizeof (SonyButtonExit); sony = 1; // set the sony button, 0 = no, 1 = yes break; case 'G': case 'g': ary = SonyButtonMenu; sz = sizeof (SonyButtonMenu); sony = 1; // set the sony button, 0 = no, 1 = yes break; case 'h': case 'H': case '?': Serial.print (SceptreHelp); button_error = 1; break; case 'I': case 'i': case '/': ary = SonyButtonGuide; sz = sizeof (SonyButtonGuide); sony = 1; // set the sony button, 0 = no, 1 = yes break; case 'K': case 'k': case '\n': ch = 'K'; // '\n' would skip a line, and not usefule for diagnostics ary = SonyButtonEnter; sz = sizeof (SonyButtonEnter); sony = 1; // set the sony button, 0 = no, 1 = yes break; // The 'k' array is the OK button and will map to the Enter key case 'L': ary = SonyButtonLeft; sz = sizeof (SonyButtonLeft); sony = 1; // set the sony button, 0 = no, 1 = yes break; case 'M': case 'm': ary = NecMute; sz = sizeof (NecMute); nec = 1; // set the nec button, 0 = no, 1 = yes break; case 'R': ary = SonyButtonRight; sz = sizeof (SonyButtonRight); sony = 1; // set the sony button, 0 = no, 1 = yes break; case 'S': case 's': ary = SonyButtonSource; sz = sizeof (SonyButtonSource); sony = 1; // set the sony button, 0 = no, 1 = yes break; case 'T': device = '1'; /* '0' = Xr2 remote, '1' = Sceptre remote */ break; case 't': device = '0'; /* '0' = Xr2 remote, '1' = Sceptre remote */ break; case 'U': ary = SonyButtonUp; sz = sizeof (SonyButtonUp); sony = 1; // set the sony button, 0 = no, 1 = yes break; case 'V': ary = SonyButtonVolUp; sz = sizeof (SonyButtonVolUp); sony = 1; // set the sony button, 0 = no, 1 = yes break; case 'v': ary = SonyButtonVolDown; sz = sizeof (SonyButtonVolDown); sony = 1; // set the sony button, 0 = no, 1 = yes break; case '+': ary = NecVolumeUp; sz = sizeof (NecVolumeUp); nec = 1; // set the nec button, 0 = no, 1 = yes break; case '-': ary = NecVolumeDown; sz = sizeof (NecVolumeDown); nec = 1; // set the nec button, 0 = no, 1 = yes break; case '\r': button_error = 1; // Set the no such button error, to prevent sending by the mySender.send function break; // CR = '\r' is ignored since the serial device may be a Unix terminal program default: Serial.write (ch); // Print the received character Serial.print (", (Ignored);"); button_error = 1; // Set the no such button error break; } break; default: /* '0' = Xr2 remote, '1' = Sceptre remote, Xr2 is default */ switch (ch) { case 'O': case 'o': case '.': ary = SonyButtonO; sz = sizeof (SonyButtonO); sony = 1; // set the sony button, 0 = no, 1 = yes break; case '0': ary = Xr2Button0; sz = sizeof (Xr2Button0); xmp = 1; // set the xmp button, 0 = no, 1 = yes break; case '1': ary = Xr2Button1; sz = sizeof (Xr2Button1); xmp = 1; // set the xmp button, 0 = no, 1 = yes break; case '2': ary = Xr2Button2; sz = sizeof (Xr2Button2); xmp = 1; // set the xmp button, 0 = no, 1 = yes break; case '3': ary = Xr2Button3; sz = sizeof (Xr2Button3); xmp = 1; // set the xmp button, 0 = no, 1 = yes break; case '4': ary = Xr2Button4; sz = sizeof (Xr2Button4); xmp = 1; // set the xmp button, 0 = no, 1 = yes break; case '5': ary = Xr2Button5; sz = sizeof (Xr2Button5); xmp = 1; // set the xmp button, 0 = no, 1 = yes break; case '6': ary = Xr2Button6; sz = sizeof (Xr2Button6); xmp = 1; // set the xmp button, 0 = no, 1 = yes break; case '7': ary = Xr2Button7; sz = sizeof (Xr2Button7); xmp = 1; // set the xmp button, 0 = no, 1 = yes break; case '8': ary = Xr2Button8; sz = sizeof (Xr2Button8); xmp = 1; // set the xmp button, 0 = no, 1 = yes break; case '9': ary = Xr2Button9; sz = sizeof (Xr2Button9); xmp = 1; // set the xmp button, 0 = no, 1 = yes break; case 'C': ary = Xr2ButtonC; sz = sizeof (Xr2ButtonC); xmp = 1; // set the xmp button, 0 = no, 1 = yes break; case 'c': ary = Xr2Buttonc; sz = sizeof (Xr2Buttonc); xmp = 1; // set the xmp button, 0 = no, 1 = yes break; case 'D': ary = Xr2Buttond; sz = sizeof (Xr2Buttond); xmp = 1; // set the xmp button, 0 = no, 1 = yes break; case 'E': case 'e': ary = Xr2ButtonE; sz = sizeof (Xr2ButtonE); xmp = 1; // set the xmp button, 0 = no, 1 = yes break; case 'G': case 'g': ary = Xr2ButtonG; sz = sizeof (Xr2ButtonG); xmp = 1; // set the xmp button, 0 = no, 1 = yes break; case 'h': case 'H': case '?': Serial.print (Xr2Help); button_error = 1; break; case 'I': case 'i': case '/': ary = Xr2ButtonI; sz = sizeof (Xr2ButtonI); xmp = 1; // set the xmp button, 0 = no, 1 = yes break; case 'K': case 'k': case '\n': ch = 'K'; // '\n' would skip a line, and not usefule for diagnostics ary = Xr2Buttonk; sz = sizeof (Xr2Buttonk); xmp = 1; // set the xmp button, 0 = no, 1 = yes break; // The 'k' array is the OK button and will map to the Enter key case 'l': case '*': ary = Xr2ButtonL; sz = sizeof (Xr2ButtonL); xmp = 1; // set the xmp button, 0 = no, 1 = yes break; case 'M': case 'm': ary = NecMute; sz = sizeof (NecMute); nec = 1; // set the nec button, 0 = no, 1 = yes break; case 'L': ary = Xr2Buttonl; sz = sizeof (Xr2Buttonl); xmp = 1; // set the xmp button, 0 = no, 1 = yes break; case 'P': ary = Xr2ButtonP; sz = sizeof (Xr2ButtonP); xmp = 1; // set the xmp button, 0 = no, 1 = yes break; case 'p': ary = Xr2Buttonp; sz = sizeof (Xr2Buttonp); xmp = 1; // set the xmp button, 0 = no, 1 = yes break; case 'R': ary = Xr2Buttonr; sz = sizeof (Xr2Buttonr); xmp = 1; // set the xmp button, 0 = no, 1 = yes break; case 'T': device = '1'; /* '0' = Xr2 remote, '1' = Sceptre remote */ break; case 't': device = '0'; /* '0' = Xr2 remote, '1' = Sceptre remote */ break; case 'U': ary = Xr2Buttonu; sz = sizeof (Xr2Buttonu); xmp = 1; // set the xmp button, 0 = no, 1 = yes break; case 'V': case '+': ary = NecVolumeUp; sz = sizeof (NecVolumeUp); nec = 1; // set the nec button, 0 = no, 1 = yes break; case 'v': case '-': ary = NecVolumeDown; sz = sizeof (NecVolumeDown); nec = 1; // set the nec button, 0 = no, 1 = yes break; case '\r': button_error = 1; // Set the no such button error, to prevent sending by the mySender.send function break; // CR = '\r' is ignored since the serial device may be a Unix terminal program default: Serial.write (ch); // Print the received character Serial.print (", (Ignored);"); button_error = 1; // Set the no such button error break; } break; } if (button_error == 0) // No such button error? { Serial.write (ch); // Print the received character if (xmp == 1) // xmp button, 0 = no, 1 = yes, set? { irsend.sendRaw (ary, sz, 38); // Pass the buffer, length, optionally frequency delayMicroseconds (40200); // delay 80.4 mS delayMicroseconds (40200); } if (sony == 1) // sony button, 0 = no, 1 = yes, set? { irsend.sendRaw (ary, sz, 40); // Pass the buffer, length, optionally frequency delayMicroseconds (10000); // delay 10 mS } if (nec == 1) // nec button, 0 = no, 1 = yes, set? { irsend.sendRaw (ary, sz, 38); // Pass the buffer, length, optionally frequency delayMicroseconds (19969); // delay 39.9375 mS delayMicroseconds (19969); } Serial.write (';'); // Terminate the print of the received character } } }