struct irparams_struct {
// The fields are ordered to reduce memory over caused by struct-paddingvolatileuint8_t rcvstate; ///< State Machine stateuint8_t recvpin; ///< Pin connected to IR data from detectoruint8_t blinkpin;
uint8_t blinkflag; ///< true -> enable blinking of pin on IR processingunsignedint rawlen; ///< counter of entries in rawbufunsignedint timer; ///< State timer, counts 50uS ticks.unsignedint rawbuf[RAW_BUFFER_LENGTH]; ///< raw datauint8_t overflow; ///< Raw buffer overflow occurred
};
#include <IRremote.h>
IRsend IrSender;
// On the Zero and others we switch explicitly to SerialUSB#if defined(ARDUINO_ARCH_SAMD)#define Serial SerialUSB#endifvoid setup() {
pinMode(LED_BUILTIN, OUTPUT);
Serial.begin(115200);
#if defined(__AVR_ATmega32U4__) || defined(SERIAL_USB) || defined(SERIAL_PORT_USBVIRTUAL)
delay(2000); // To be able to connect Serial monitor after reset and before first printout#endif// Just to know which program is running on my Arduino
Serial.println(F("START "__FILE__" from "__DATE__));
Serial.print(F("Ready to send IR signals at pin "));
Serial.println(IR_SEND_PIN); //IR_SEND_PIN=5
}
void loop() {
int khz = 38; // 38kHz carrier frequency for the NEC protocol/* * Send data from RAM */unsignedint irSignal[] = {1250,450, 1200,500, 350,1300, 1250,450, 400,1300, 400,1250, 450,1250, 1200,500, 400,1250, 1250,450, 400,1300, 350};
Serial.print("send data:");
for(int i=0; i<sizeof(irSignal); i++){
Serial.print(sizeof(irSignal));
Serial.print(",");
}
Serial.println("");
for(int i=0; i <3; i++){
IrSender.sendRaw(irSignal, sizeof(irSignal) / sizeof(irSignal[0]), khz); // Note the approach used to automatically calculate the size of the array.
}
delay(2000);
}
Use the IRrecvDumpV2 example to dump out the IR timing. You can then reproduce/send this timing with the IRsendRawDemo example. For long codes like from air conditioners, you can change the length of the input buffer in IRremoteInt.h.