I included it in the IRremote library, loaded in arduino aaaand it doesn't work.
I know there a billions of reason why it doesn't and I'd like to narrow the options.
Below there's my implementation of the protocol I found, could you please let me know if it is correct?
In particular I have no idea of what "toggle_bit_mask" means, nor what the gap is, since there is no minimum repeat value indicated.
Thanks in advance:
send function :
void IRsend::sendSamsung(unsigned long data, int nbits,int repeat){
enableIROut(40);
if (repeat == 0) {
mark(SAMSUNG_HDR_MARK);
space(SAMSUNG_HDR_SPACE);
}
//Invio il pre_data 0xE0E0 del protocollo http://lirc.sourceforge.net/remotes/samsung/AA59-00382A
unsigned long pre_data = 0xE0E0;
pre_data <<= 16;
for (int i = 0; i < 16; i++) {
if (pre_data & TOPBIT) {
mark(SAMSUNG_ONE_MARK);
space(SAMSUNG_ONE_SPACE);
}
else {
mark(SAMSUNG_ONE_MARK);
space(SAMSUNG_ZERO_SPACE);
}
pre_data <<= 1;
}
//Ora trasmetto il mio segnale
data = data << (32-nbits);
for (int i = 0; i < 16; i++) {
if (data & TOPBIT) {
mark(SAMSUNG_ONE_MARK);
space(SAMSUNG_ONE_SPACE);
}
else {
mark(SAMSUNG_ONE_MARK);
space(SAMSUNG_ZERO_SPACE);
}
data <<= 1;
}
//aggiungo il trail
mark(SAMSUNG_PTRAIL);
}
Ok, I managed to get this things work.
I post here the solution in case someone had to do the same thing:
It was wrong to not send the header when repeating the signal, so the code now is :
void IRsend::sendSamsung(unsigned long data, int nbits,int repeat){
enableIROut(38);
mark(SAMSUNG_HDR_MARK);
space(SAMSUNG_HDR_SPACE);
//Invio il pre_data 0xE0E0 del protocollo http://lirc.sourceforge.net/remotes/samsung/AA59-00382A
unsigned long pre_data = 0xE0E0;
pre_data <<= 16;
for (int i = 0; i < 16; i++) {
if (pre_data & TOPBIT) {
mark(SAMSUNG_ONE_MARK);
space(SAMSUNG_ONE_SPACE);
}
else {
mark(SAMSUNG_ONE_MARK);
space(SAMSUNG_ZERO_SPACE);
}
pre_data <<= 1;
}
//Ora trasmetto il mio segnale
data = data << (32-nbits);
for (int i = 0; i < 16; i++) {
if (data & TOPBIT) {
mark(SAMSUNG_ONE_MARK);
space(SAMSUNG_ONE_SPACE);
}
else {
mark(SAMSUNG_ONE_MARK);
space(SAMSUNG_ZERO_SPACE);
}
data <<= 1;
}
//aggiungo il trail
mark(SAMSUNG_PTRAIL);
space(48962); //gap
}
note that i moved the gap here from the sketch.
It was a pointbreak find this legend to read lirc files : Technical Details
And I suggest also reading the blog of the library's creator, just google IRremote library and you should find him.
If I may help someone with this kind of project let me know, and thanks to johnwasser for finding that mistake
I would like to try this out on my Samsung. I created a sketch from this code and get a compilation error. "no void IRsend::sendSamsung(unsigned int, int ,int ) member function declared in iRsend". Is there a special place that function should reside?
philG:
I would like to try this out on my Samsung. I created a sketch from this code and get a compilation error. "no void IRsend::sendSamsung(unsigned int, int ,int ) member function declared in iRsend". Is there a special place that function should reside?
You have to add it to the IRremote library, in both IRremote.h and IRremote.cpp. You might as well add it to keywords.txt, too.
Oh, right. I have it compiling now. I think the code assumes that the LED will be driven directly off the pin. I plan to use an NPN driver so I will have to invert the output. I'm not sure is that can be done easily in the PWM setup. Thanks for the help John.
OK, this works fine. I was not sure why there was a loop around the send command since there is a repeat count parameter. I added defines for all the useful commands and built a sequence of commands that turns on the TV and sets the source to the DTV STB.
I am wondering why I can't find the hex codes for the DTV RC65 remote anywhere. Is there some legal issue?