how to create a 38KHz signal pulsed at 10Hz. ?

I want to create a square wave of 38 KHz pulsed at 10hz to be fed to an IR led so a receiver can read it's value and figure it out the distance from 0 to 255.

I tried making a pin high and low for 13 microseconds but it doesn't seem to work.

Is there a way by using a timer or something else to achieve this purpose ?

Thanks

The easiest way might be to feed 38khz into the anode of a diode (1N914), cathode to a series 220R resistor to the base/gate of a NPN/NchannelMOSFET transistor, emitter/source to GND.

The feed 10hz to the anode of a 2nd diode, the cathodes of both diodes are connected.

Anode of IR diode to +5v cathode to a 50 Ω resistor then to the collector/drain of the transistor.

If using MOSFET, cathodes of the two drive diodes to a 10k resistor to GND.

Does your project require the 38 kHz signal to be phase coherent with the on-off signal? In other words, can the 38 kHz signal be chopped short or long?

Paul

the 38kHz signal needs to be synced with the 10hz

here is an image of what i'm trying to do

“ the 38kHz signal needs to be synced with the 10hz”

Why?

If this is for detection, you just need on/off at 10hz controlling 38khz.

I think 38khz might be the typical IR remote control frequency, so you might look for some remote control modules to make the project easier.

You can't get exactly 38 kHz with a 16 MHz Arduino timer since 16000000 / 38000 = 210.5263 clock ticks per half cycle. Would 37914.7 Hz be close enough?

37914.7 Hz would be fine i guess

You may be missing understanding the keying of the 38khz signal.

For 38khz, use the tone function:

const byte thirty8khzPin = 8;
const byte tenHertzPin = 9;
. . .
tone(thirty8khzPin, 38000);

For the 10hz, a simple timer using millis() BWD will work, toggle the tenHertzPin.

Note: to stop the keying, stop toggling the tenHertzPin, then digitalWrite(tenHertzPin, HIGH);