IR Emitter with Arduino

Hi All,

I’m trying to use the Arduino with an IR emitter to send IR codes to a light dimmer switch. The requirement of the dimmer switch is that the codes being sent must be at 40% duty cycle with a 40 kHz frequency. I can do this with timers or bit banging but the signal outputted is not very accurate and contains a lot of jitter. My next idea was to use the Arduino to output a PWM at 40% duty with the command

analogWrite( <out_pin>, 102);

and use a PLL to frequency multiply it to 40 kHz since the PWM output is at 1 kHz. I’ve never done this before so unsure if this is logically/physically possible. So my question would be, is this method viable? If not, what other methods are worth a look in to?

Thanks.