IRRemote library conflicts with tone() function

I am new to the forum so pardon my typing and english. :slight_smile:

I am making turntable for 360 photography. (on Arduino UNO)

I had working sketch for Canon (triggered with IR led) (ref and code from: GitHub - roboanat/photo-turntable: DIY Automatic photo turntable with Arduino)

I want to work same for Nikon & canon both so I find IR code for Nikon, which gives me problem with tone() code. Which solved by above help (changing timer2 to timer1) and its working fine with Nikon.

But it stop working for canon now.

I want to use same IR LED for both cameras, though both have different codes for it

Please find attached sketch file (which I altered as per my retirement)

Note: other supporting files/libraries are from above github link, i didnt change anything in those files, except "IRremoteInt.h" as per above topic.

Below are 2 IR signal for both cameras from attached file (rest of the sketch are tested OK)

// for canon ------------------------------ this code from original from github

void irStillsShot() {
int khz = 33; // 33kHz frequency
unsigned int irSignal[] = {480};
ir_led.sendRaw(irSignal, sizeof(irSignal) / sizeof(irSignal[0]), khz);
delayMicroseconds(7330);
ir_led.sendRaw(irSignal, sizeof(irSignal) / sizeof(irSignal[0]), khz);
}

// for nikon ---------------------------- this is from some other program for nikon

void shutterClick() {
tone(IRPin,38000);
delay(2);
noTone(IRPin);
delay(28);//original delay 28ms
tone(IRPin,38000);
delayMicroseconds(200);
noTone(IRPin);
delayMicroseconds(1500);
tone(IRPin,38000);
delayMicroseconds(200);
noTone(IRPin);
delayMicroseconds(3300);
tone(IRPin,38000);
delayMicroseconds(200);
noTone(IRPin); // 65ms delay before repeat
}


Note: IR is assign to pin 3.

Now ---- If i compile sketch as it is then it give tone() conflict error, coz tone() is conflict with timer2, may be it is in use.

But --- If I change timer2 to timer1 in "IRremoteInt.h" then nikon works fine but canon code have no LED working.

Now my main question is that in which code I am making mistake... in canon or in nikon. And is it possible to work like this with same LED? If yes then I might put my more time for the same. If not then I might have to use MEGA or make 2 different module for 2 cameras.

Hope I explain it proper and someone might help me with this.

Thanks in advance.

Firmware.ino (11.3 KB)