Controlling PilotLamp over a pin using different frequencies

I am including a x-Arcraft pilotlamp into a multicopter project ond Arduino Pro Mini, Pro Micro and Mega and having trouble with my cycle time.
The patterns I try to send are getting fuzzy and the buzzer goes havok.

The PilotLamp is controlled via frequencies:
It has three LEDS and a buzzer each channel has a distinct frequency for on and off.
If I want to activate the blue LED I have to send the frequency for “Blue LED on” 3 rectangular cycles as a PPM with 50% uptime: |-||-||-|___

But the buzzerchannel needs this to be achieved with 625Hz.

I downloaded a solution using a for statement but this is slowing my main cycle down and reacting weird. It has to be around 3ms +2ms

void gen_pl_freq(uint16_t device)
      uint8_t i;
      for (i=0;i<3;i++) {                                // Four waveforms are required. maybe three??

How can I make it more elegant and faster?
I heard of timers, I am new to processing and arduino and have only coded stuff like alarm beeps and other easy stuff yet.

Thank you very much


ps.: If you need more precise infos please tell me.

I would try the tone(pin, frequency) function:

Hi, that seems to be a solution. Wi didn't I notice that? Is this function executed as a background thread?

I fear it will interfere with the PWM outputs on the pro mini and pro micro.

But it is a good start. Thank you very much.


Is this function executed as a background thread?

On a single threaded system? How would that be possible?

Hi, you are right, I meant in background like a timer, but after reading the function definition carefully I found the answer to my question. It is executed and handled in abckground. This is what I am looking for. Although it does interfere with the timers on the Pro Mini.

I think I have to read myself into timer handling :-(