/* IRremoteESP8266: IRsendDemo - demonstrates sending IR codes with IRsend.
*
* Version 1.1 January, 2019
* Based on Ken Shirriff's IrsendDemo Version 0.1 July, 2009,
* Copyright 2009 Ken Shirriff, http://arcfn.com
*
* An IR LED circuit *MUST* be connected to the ESP8266 on a pin
* as specified by kIrLed below.
*
* TL;DR: The IR LED needs to be driven by a transistor for a good result.
*
* Suggested circuit:
* https://github.com/crankyoldgit/IRremoteESP8266/wiki#ir-sending
*
* Common mistakes & tips:
* * Don't just connect the IR LED directly to the pin, it won't
* have enough current to drive the IR LED effectively.
* * Make sure you have the IR LED polarity correct.
* See: https://learn.sparkfun.com/tutorials/polarity/diode-and-led-polarity
* * Typical digital camera/phones can be used to see if the IR LED is flashed.
* Replace the IR LED with a normal LED if you don't have a digital camera
* when debugging.
* * Avoid using the following pins unless you really know what you are doing:
* * Pin 0/D3: Can interfere with the boot/program mode & support circuits.
* * Pin 1/TX/TXD0: Any serial transmissions from the ESP8266 will interfere.
* * Pin 3/RX/RXD0: Any serial transmissions to the ESP8266 will interfere.
* * ESP-01 modules are tricky. We suggest you use a module with more GPIOs
* for your first time. e.g. ESP-12 etc.
*/
#include <Arduino.h>
#include <IRremoteESP8266.h>
#include <IRsend.h>
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.
// Example of data captured by IRrecvDumpV2.ino
//uint16_t rawData[67] = {9000, 4500, 650, 550, 650, 1650, 600, 550, 650, 550,
// 600, 1650, 650, 550, 600, 1650, 650, 1650, 650, 1650,
// 600, 550, 650, 1650, 650, 1650, 650, 550, 600, 1650,
// 650, 1650, 650, 550, 650, 550, 650, 1650, 650, 550,
// 650, 550, 650, 550, 600, 550, 650, 550, 650, 550,
// 650, 1650, 600, 550, 650, 1650, 650, 1650, 650, 1650,
// 650, 1650, 650, 1650, 650, 1650, 600};
uint16_t rawData[257] = {516, 988, 478, 528, 476, 1014, 494, 530, 476, 530, 474, 1014, 516, 508, 498, 986, 520, 488, 520, 982, 490, 518, 516, 988, 500, 988, 520, 506, 500, 984, 518, 488, 520, 488, 518, 506, 500, 504, 500, 506, 498, 506, 442, 564, 514, 494, 522, 488, 516, 506, 500, 504, 500, 504, 500, 504, 486, 520, 516, 492, 520, 488, 520, 504, 500, 982, 518, 490, 522, 486, 520, 504, 500, 504, 500, 504, 500, 506, 486, 520, 516, 490, 520, 488, 518, 504, 500, 504, 500, 504, 500, 506, 474, 530, 520, 488, 520, 486, 518, 504, 500, 504, 500, 504, 500, 504, 416, 590, 514, 492, 520, 448, 566, 498, 498, 506, 500, 504, 500, 504, 476, 530, 488, 518, 518, 490, 520, 488, 516, 504, 500, 504, 500, 504, 500, 504, 416, 590, 514, 492, 520, 488, 518, 504, 500, 504, 500, 504, 500, 504, 500, 506, 486, 520, 516, 490, 520, 486, 518, 504, 500, 506, 500, 504, 500, 504, 418, 588, 514, 494, 518, 490, 518, 506, 500, 504, 500, 504, 500, 506, 498, 508, 484, 522, 516, 492, 518, 488, 518, 506, 500, 504, 500, 504, 500, 506, 416, 590, 488, 518, 518, 490, 518, 506, 498, 506, 498, 506, 498, 506, 498, 506, 418, 590, 516, 492, 518, 488, 516, 506, 498, 506, 498, 506, 498, 506, 418, 588, 488, 518, 516, 490, 516, 506, 498, 506, 498, 506, 498, 506, 476, 530, 416, 590, 514, 494, 518, 488, 516, 506, 498, 506, 498, 506, 498, 506, 418}; // UNKNOWN B4C0FCA9
//uint16_t rawData[257] = {510, 998, 544, 460, 544, 942, 562, 462, 544, 460, 542, 942, 536, 468, 538, 964, 508, 498, 534, 970, 542, 464, 544, 962, 520, 966, 534, 472, 536, 968, 542, 462, 508, 498, 534, 472, 538, 468, 536, 488, 518, 488, 516, 488, 542, 498, 504, 428, 564, 482, 532, 472, 534, 490, 514, 490, 514, 490, 514, 490, 544, 462, 508, 498, 530, 476, 532, 474, 532, 492, 512, 492, 512, 492, 512, 492, 544, 462, 506, 500, 528, 478, 530, 494, 510, 494, 510, 494, 512, 494, 542, 462, 508, 498, 526, 480, 528, 972, 544, 962, 508, 496, 508, 496, 510, 494, 544, 462, 524, 482, 524, 480, 526, 498, 506, 498, 506, 500, 506, 498, 544, 462, 522, 484, 524, 480, 524, 500, 504, 500, 504, 982, 524, 482, 522, 502, 502, 502, 504, 500, 504, 500, 544, 462, 544, 462, 546, 460, 520, 502, 504, 502, 502, 502, 504, 500, 540, 466, 544, 462, 546, 460, 546, 478, 526, 478, 526, 478, 526, 478, 506, 500, 542, 464, 544, 462, 546, 460, 542, 478, 526, 480, 526, 478, 504, 502, 508, 498, 542, 464, 546, 460, 544, 480, 526, 478, 526, 478, 526, 478, 504, 500, 540, 466, 542, 464, 546, 462, 544, 478, 524, 480, 526, 478, 526, 478, 506, 502, 538, 468, 542, 464, 544, 480, 524, 480, 526, 478, 526, 480, 502, 504, 504, 500, 540, 466, 544, 464, 542, 480, 524, 480, 524, 480, 524, 964, 542, 480, 600, 440, 488, 482, 524, 480, 504, 502, 534}; // UNKNOWN D8396229
//uint16_t rawData[257] = {536, 966, 544, 462, 506, 998, 512, 490, 516, 488, 544, 962, 514, 490, 516, 988, 514, 490, 512, 972, 530, 476, 530, 972, 510, 996, 514, 492, 512, 974, 532, 492, 512, 492, 510, 494, 510, 492, 544, 462, 506, 498, 528, 478, 530, 496, 510, 494, 508, 494, 508, 496, 544, 462, 524, 480, 526, 480, 526, 498, 508, 496, 506, 496, 508, 496, 544, 462, 542, 464, 524, 480, 526, 498, 506, 498, 506, 498, 508, 496, 540, 466, 542, 462, 522, 482, 524, 482, 524, 498, 504, 500, 504, 500, 504, 500, 542, 962, 506, 980, 526, 484, 520, 500, 504, 500, 504, 500, 506, 500, 542, 462, 546, 460, 546, 460, 522, 502, 502, 500, 504, 502, 502, 502, 508, 498, 544, 462, 544, 460, 546, 954, 542, 464, 544, 462, 546, 460, 562, 484, 504, 478, 526, 478, 526, 478, 504, 500, 542, 464, 546, 460, 544, 478, 526, 478, 526, 478, 526, 478, 504, 500, 540, 466, 542, 464, 546, 460, 544, 478, 526, 478, 526, 478, 526, 480, 506, 500, 540, 466, 544, 462, 544, 478, 526, 478, 526, 478, 526, 478, 502, 502, 506, 498, 540, 466, 544, 462, 544, 478, 526, 478, 526, 478, 526, 478, 504, 502, 538, 466, 542, 464, 544, 462, 542, 478, 526, 478, 526, 478, 526, 478, 506, 500, 538, 466, 544, 462, 542, 480, 524, 480, 524, 480, 524, 480, 504, 502, 506, 498, 540, 466, 544, 464, 542, 958, 508, 500, 544, 462, 542, 480, 524, 480, 524, 480, 524}; // UNKNOWN D8396229
//uint16_t rawData[257]={42330, 0, 512, 0, 0, 0, 0, 1, 42330, 0, 512, 0, 0, 0, 0, 421, 23040, 2, 0, 0, 0, 0, 0, 421, 0, 512, 0, 0, 0, 0, 1, 42330, 0, 512, 0, 0, 0, 0, 421, 23040, 2, 0, 0, 0, 0, 0, 421, 23040, 512, 0, 0, 0, 0, 1, 42330, 0, 512, 0, 0, 0, 0, 421, 23040, 2, 0, 0, 0, 0, 0};
// Example Samsung A/C state captured from IRrecvDumpV2.ino
//uint8_t samsungState[kSamsungAcStateLength] = {
// 0x02, 0x92, 0x0F, 0x00, 0x00, 0x00, 0xF0,
// 0x01, 0xE2, 0xFE, 0x71, 0x40, 0x11, 0xF0};
void setup() {
irsend.begin();
#if ESP8266
Serial.begin(115200, SERIAL_8N1, SERIAL_TX_ONLY);
#else // ESP8266
Serial.begin(115200, SERIAL_8N1);
#endif // ESP8266
}
void loop() {
// irsend.sendNEC(0x00D8396229,32);
//Serial.println("NEC");
// irsend.sendNEC(0x00D8396229);//0x00FFE01FUL
delay(2000);
// irsend.sendGeneric(0,0,0,0,0,0,0,0,0xD8396229,129,38,0,2,50);
// Serial.println("Sony");
// irsend.sendSony(0xa90, 12, 2); // 12 bits & 2 repeats
// delay(2000);
Serial.println("a rawData capture from IRrecvDumpV2");
irsend.sendRaw(rawData,257, 38); // Send a raw data capture at 38kHz.
delay(2000);
// Serial.println("a Samsung A/C state from IRrecvDumpV2");
// irsend.sendSamsungAC(samsungState);
// delay(2000);
}