Emulating IR receiver signal with Arduino

Hi,

I need to emulate IR processed receiver signal – basically cut signal wire from IR receiver, connect it to Arduino pin and emulate IR.
I already decoded signal and know all timings, but I hit the wall while trying to emulate them.

Signal parameters:
Signal “opens” with 9ms “low” (wire pulled up by default), 5ms high and then data pulses: “0”- 0.6ms, “1”- 1.75ms, between - 0.6ms “low”.

“delayMicroseconds()” between pulses for some reason isn’t clean – it varies too much.
Is there a way to emulate this with PWM (compared with timings it seems that this is default 976hz PWM frequency of pin11)? I never came across issue like this, how should I solve it? Is there a way to control individual PWM pulse?

Thank You in advance.

Please post the code that you tried

UKHeliBob:
Please post the code that you tried

Theres no code to post – I used a blink sketch but instead of "dalay()" I used "delayMicroseconds()" and watched output on oscilloscope – pulses aren't stable.

3Dgeo:
Theres no code to post – I used a blink sketch but instead of "dalay()" I used "delayMicroseconds()" and watched output on oscilloscope – pulses aren't stable.

If your code doesn't need to do anything else, just put noInterrupts() before the pulses and interrupts() after the pulses.

3Dgeo:
I used a blink sketch but instead of "dalay()" I used "delayMicroseconds()"

No, that won't work. When loop() ends, some things go on in the background before loop() is called again, making that method unstable. You need to put all the code to send your data into one execution of loop().

Try this

void loop() {
  while (1) {
    digitalWrite(pin, HIGH);
    delayMicroseconds(100);
    digitalWrite(pin, LOW);
    delayMicroseconds(100);
  }
}

PaulRB:
No, that won't work. When loop() ends, some things go on in the background before loop() is called again, making that method unstable. You need to put all the code to send your data into one execution of loop().

Try this

void loop() {

while (1) {
    digitalWrite(pin, HIGH);
    delayMicroseconds(100);
    digitalWrite(pin, LOW);
    delayMicroseconds(100);
  }
}

This solves the problem, thank You!