Infrared experiment- wheres this code from?

I am musing for the next project , about using infrared to replace the wireless modules that I normally use .

I use either VirtualWire with the simplex modules, and lately SerialEasyTransfer with SIM20 modules.

I want to experiment with using an IR link having the VirtualWire ( or SET ) data gating 38Khz bursts of data and the receiver using a normal IR detect module, straight into the Rx ( or possibly inverted ) I can play with the baudrate to match the receivers bandwidth.

The VW library uses a preamble and manchester code, which might work well with the IR receiver.

All the IR projects I can find on the forum/playground are using one of the TV remote codes, which I am not interested in.

I want to knock up a quick experiment between 2 arduinos, and found the following code on Sparkfun for generating the 38Khz pulses, turned on and off at 500ms intervals

void setup() {                
  // toggle pin 11 on compare
  TCCR2A = _BV(WGM21) | _BV(COM2A0);
  TCCR2B = _BV(CS20);
  
  // 38kHz timer
  OCR2A = (F_CPU/(IR_CLOCK_RATE*2L)-1);
  pinMode(11, OUTPUT); 
void loop() {
  //turn the 38kHz carrier wave off and on            
  TCCR2B = 0;
  delay(500);
  TCCR2B = _BV(CS20);
  delay(500);
}

It works fine, the 38Khz is accurate, but the output when it toggles off can be left either high or low, which would be bad for driving ( via a transisitor ) an IR LED at high power, as it would burn out if the gaps were high - I could use a cap in the driver, but I am sure there must be a way of holdng pin11 low. TCCR2B = 0 perhaps ?or might that also leave the output high?

The trouble is I have no idea where this code comes from, there are no libraries called, and I did a search in the Arduino22 folder, but nothing.

I want to be able to gate this with the VW data ( even if I loop the VW Tx pin back into an input pin for the mock up experiment)

Perhaps I can digitalWrite pin 11 low when I want no output, or would it upset the toggling ?

Right, I tried running the above code as a seperate 38Khz generator, with the idea of feeding it to a transisitor, and externally gating the VirtualWire data with a diode.

As soon as I set the VW, however , the 38Khz dies, so I am going to use a separate 555 timer to generate the 38Khz ( cutting edge eh? ) for the experiment, and come back later to the internal gating.