I try to create a remote infrared controler from arduino. I begin to emulate the canon wl-dc100 remote because the only digital camera I have is a Canon one.
I find the ir code for this remote here http://www.icb.chel.su/~sapa/lj/rc/pic_v4m.asm and here http://lirc.sourceforge.net/remotes/canon/WL-DC100.
Unfortunatly my code doesn't seem to work. The IR led work (I can see it lighting with my digital camera) but the camera doesn't seem to responde to my ir.
Do you see anything strange in my code?
/* Exemple Emetteur WL-DC100 */
/* Jean-Christophe DURANTON 24/12/2007 */
#define LEDIR 3 // n° broche numérique de l'anode de la LED infrarouge
int wldc_zero[] = {612,512};
int wldc_one[] = {612,1621};
int wldc_header[] = {9042,4379};
int wldc_ptrail[] = {599,107448};
int wldc_repeat[] = {9039,2115};
int wldc_bits = 16;
int wldc_prebits = 16;
int wldc_predata = 0x538D; // 0101001110001101
int wldc_snap = 0xF807; // 1111100000000111
int wldc_zoomin = 0x42BD; // 0100001010111101
int wldc_zoomout = 0xC23D; // 1100001000111101
void sendIRvalue(int value[])
{
digitalWrite(LEDIR, HIGH);
delayMicroseconds(value[0]);
digitalWrite(LEDIR, LOW);
delayMicroseconds(value[1]);
}
void sendIRCodes(int hexval,int bytval)
{
int cmp;
int result[bytval];
for(int itmp=0; itmp < bytval; itmp++)
{
int cmp = 1 << itmp;
if ((hexval | cmp) == hexval)
{
result[bytval-1-itmp] = 1;
}else
{
result[bytval-1-itmp] = 0;
}
}
for(int jtmp=0; jtmp < bytval; jtmp++)
{
if(result[jtmp] == 1)
{
sendIRvalue(wldc_one);
}else
{
sendIRvalue(wldc_zero);
}
}
}
void setup ()
{
pinMode (LEDIR, OUTPUT);
}
void loop ()
{
//header
sendIRvalue(wldc_header);
//predata
sendIRCodes(wldc_predata,wldc_prebits);
//snap
sendIRCodes(wldc_snap,wldc_bits);
//ptrail
sendIRvalue(wldc_ptrail);
delay(5000);
}
The most likely reason that it isn't working is because the IR needs to oscillate at a certain frequency (Usually 38kHz) so the reciever can see it. This is what's known as a carrier signal.
I'm looking at porting the TV-B-Gone to the Arduino, and along my travels I've learnt that modifying the PWM timers isn't the best way to go for this. Look at the 555 Timer ICs, with the correct capacitor and resistor combo you should be able to oscillate your IR LED at the right frequency - to find the correct frequency check the manual or look to your friend google.
On that note, does anyone out there know what cap/resistor I should go for in order to get a 555 timer to put out a 37.916kHz oscillation? I'm not even sure if you can get that precise, 38kHz should do fine.