Byork:
JD, sure here's what I did. Both receiving and sending are tested on Uno and Nano.For receiving the signal, I am using the TSOP4838, connected to pin 2 according to the sketch. After pressing the button on your AC remote, you may need to wait up to 5 seconds for the code to appear in serial monitor. The sketch I used was:
#define LEDPIN 13
//you may increase this value on Arduinos with greater than 2k SRAM
#define maxLen 800
volatile unsigned int irBuffer[maxLen]; //stores timings - volatile because changed by ISR
volatile unsigned int x = 0; //Pointer thru irBuffer - volatile because changed by ISR
void setup() {
Serial.begin(115200); //change BAUD rate as required
attachInterrupt(0, rxIR_Interrupt_Handler, CHANGE);//set up ISR for receiving IR signal
}
void loop() {
// put your main code here, to run repeatedly:
Serial.println(F("Press the button on the remote now - once only"));
delay(5000); // pause 5 secs
if (x) { //if a signal is captured
digitalWrite(LEDPIN, HIGH);//visual indicator that signal received
Serial.println();
Serial.print(F("Raw: (")); //dump raw header format - for library
Serial.print((x - 1));
Serial.print(F(") "));
detachInterrupt(0);//stop interrupts & capture until finshed here
for (int i = 1; i < x; i++) { //now dump the times
if (!(i & 0x1)) Serial.print(F("-"));
Serial.print(irBuffer[i] - irBuffer[i - 1]);
Serial.print(F(", "));
}
x = 0;
Serial.println();
Serial.println();
digitalWrite(LEDPIN, LOW);//end of visual indicator, for this time
attachInterrupt(0, rxIR_Interrupt_Handler, CHANGE);//re-enable ISR for receiving IR signal
}
}
void rxIR_Interrupt_Handler() {
if (x > maxLen) return; //ignore if irBuffer is already full
irBuffer[x++] = micros(); //just continually record the time-stamp of signal transitions
}
My AC IR code received was this:
Raw: (439) 3552, -1664, 508, -364, 508, -1232, 504, -364, 508, -360, 508, -364, 504, -364, 504, -364, 508, -364, 504, -364, 504, -364, 508, -364, 504, -364, 504, -364, 504, -1236, 504, -364, 504, -364, 508, -364, 504, -364, 504, -364, 504, -364, 508, -364, 504, -1232, 508, -1232, 480, -1256, 484, -392, 480, -388, 480, -1256, 484, -388, 480, -388, 480, -392, 504, -364, 480, -388, 508, -360, 508, -364, 480, -388, 504, -364, 508, -364, 504, -364, 504, -364, 504, -364, 508, -364, 504, -364, 504, -364, 504, -368, 504, -364, 504, -364, 504, -364, 508, -364, 504, -364, 508, -360, 508, -364, 504, -364, 504, -364, 508, -364, 504, -368, 476, -392, 476, -392, 480, -1256, 484, -1256, 508, -364, 504, -364, 504, -364, 508, -360, 508, -364, 504, -10884, 3528, -1688, 504, -368, 504, -1232, 484, -384, 484, -388, 484, -384, 484, -384, 484, -384, 484, -392, 504, -364, 504, -364, 508, -364, 504, -364, 504, -364, 508, -1228, 508, -364, 504, -364, 508, -364, 504, -364, 504, -368, 504, -364, 504, -364, 504, -1232, 508, -1232, 508, -1232, 504, -364, 508, -364, 504, -1232, 504, -364, 508, -364, 504, -364, 504, -364, 508, -364, 504, -364, 504, -364, 504, -364, 508, -364, 504, -364, 504, -364, 508, -364, 504, -364, 504, -364, 508, -364, 504, -364, 504, -1236, 504, -1232, 480, -1260, 484, -384, 484, -384, 484, -384, 484, -388, 484, -384, 508, -368, 476, -1256, 508, -1228, 512, -364, 504, -364, 504, -364, 508, -364, 504, -364, 504, -364, 504, -364, 508, -364, 504, -364, 504, -1236, 504, -1232, 504, -364, 508, -364, 504, -364, 504, -1236, 504, -1232, 480, -388, 480, -392, 484, -384, 480, -388, 484, -388, 484, -384, 484, -384, 484, -392, 480, -388, 480, -388, 480, -388, 508, -364, 504, -364, 504, -364, 504, -364, 508, -364, 504, -364, 504, -364, 508, -364, 504, -1232, 504, -1236, 504, -1232, 504, -364, 508, -364, 504, -364, 480, -388, 480, -392, 476, -392, 480, -392, 480, -388, 480, -392, 480, -1252, 512, -1232, 504, -1232, 508, -364, 504, -364, 504, -364, 504, -368, 504, -364, 504, -364, 504, -364, 504, -364, 508, -364, 504, -364, 504, -364, 508, -368, 472, -396, 476, -392, 476, -392, 476, -396, 476, -1256, 484, -392, 476, -392, 480, -388, 480, -388, 508, -364, 504, -364, 504, -1236, 504, -364, 504, -364, 504, -364, 508, -364, 504, -364, 504, -364, 504, -364, 508, -364, 504, -364, 504, -364, 508, -364, 504, -368, 500, -368, 500, -368, 476, -396, 476, -392, 476, -392, 476, -1260, 484, -1252, 484, -1260, 480, -388, 504, -364, 508, -364, 504, -1232, 508
You then need to remove all the negative signs using a text editor. After which I used and inserted my IR code into this sketch. The IR emitter LED is connected to pin 3 as according to the sketch:
/*
- IRremote: IRsendRawDemo - demonstrates sending IR codes with sendRaw
- An IR LED must be connected to Arduino PWM pin 3.
- Version 0.1 July, 2009
- Copyright 2009 Ken Shirriff
- http://arcfn.com
- IRsendRawDemo - added by AnalysIR (via www.AnalysIR.com), 24 August 2015
*/
#include <IRremote.h>
IRsend irsend;
void setup()
{
}
void loop() {
int khz = 38; // 38kHz carrier frequency for the NEC protocol
unsigned int irSignal[] = {3552, 1664, 508, 364, 508, 1232, 504, 364, 508, 360, 508, 364, 504, 364, 504, 364, 508, 364, 504, 364, 504, 364, 508, 364, 504, 364, 504, 364, 504, 1236, 504, 364, 504, 364, 508, 364, 504, 364, 504, 364, 504, 364, 508, 364, 504, 1232, 508, 1232, 480, 1256, 484, 392, 480, 388, 480, 1256, 484, 388, 480, 388, 480, 392, 504, 364, 480, 388, 508, 360, 508, 364, 480, 388, 504, 364, 508, 364, 504, 364, 504, 364, 504, 364, 508, 364, 504, 364, 504, 364, 504, 368, 504, 364, 504, 364, 504, 364, 508, 364, 504, 364, 508, 360, 508, 364, 504, 364, 504, 364, 508, 364, 504, 368, 476, 392, 476, 392, 480, 1256, 484, 1256, 508, 364, 504, 364, 504, 364, 508, 360, 508, 364, 504, 10884, 3528, 1688, 504, 368, 504, 1232, 484, 384, 484, 388, 484, 384, 484, 384, 484, 384, 484, 392, 504, 364, 504, 364, 508, 364, 504, 364, 504, 364, 508, 1228, 508, 364, 504, 364, 508, 364, 504, 364, 504, 368, 504, 364, 504, 364, 504, 1232, 508, 1232, 508, 1232, 504, 364, 508, 364, 504, 1232, 504, 364, 508, 364, 504, 364, 504, 364, 508, 364, 504, 364, 504, 364, 504, 364, 508, 364, 504, 364, 504, 364, 508, 364, 504, 364, 504, 364, 508, 364, 504, 364, 504, 1236, 504, 1232, 480, 1260, 484, 384, 484, 384, 484, 384, 484, 388, 484, 384, 508, 368, 476, 1256, 508, 1228, 512, 364, 504, 364, 504, 364, 508, 364, 504, 364, 504, 364, 504, 364, 508, 364, 504, 364, 504, 1236, 504, 1232, 504, 364, 508, 364, 504, 364, 504, 1236, 504, 1232, 480, 388, 480, 392, 484, 384, 480, 388, 484, 388, 484, 384, 484, 384, 484, 392, 480, 388, 480, 388, 480, 388, 508, 364, 504, 364, 504, 364, 504, 364, 508, 364, 504, 364, 504, 364, 508, 364, 504, 1232, 504, 1236, 504, 1232, 504, 364, 508, 364, 504, 364, 480, 388, 480, 392, 476, 392, 480, 392, 480, 388, 480, 392, 480, 1252, 512, 1232, 504, 1232, 508, 364, 504, 364, 504, 364, 504, 368, 504, 364, 504, 364, 504, 364, 504, 364, 508, 364, 504, 364, 504, 364, 508, 368, 472, 396, 476, 392, 476, 392, 476, 396, 476, 1256, 484, 392, 476, 392, 480, 388, 480, 388, 508, 364, 504, 364, 504, 1236, 504, 364, 504, 364, 504, 364, 508, 364, 504, 364, 504, 364, 504, 364, 508, 364, 504, 364, 504, 364, 508, 364, 504, 368, 500, 368, 500, 368, 476, 396, 476, 392, 476, 392, 476, 1260, 484, 1252, 484, 1260, 480, 388, 504, 364, 508, 364, 504, 1232, 508};
irsend.sendRaw(irSignal, sizeof(irSignal) / sizeof(irSignal[0]), khz); //Note the approach used to automatically calculate the size of the array.
delay(5000); //In this example, the signal will be repeated every 5 seconds, approximately.
}
I am having the same Problem and tried above code also and method but then also it's not working I am getting 439 and 238 long codes. Please Help.