# I wanna make 38kHz frequency signal.

I will wanna make the IR communication, so I need to make 38kHz.

The operation that I wanna do is just simple.
The transmitter is turned on, the receiver captures this signal and turns on LED.

How can I make the 38kHz frequency?
I will really appreciate that if someone shows some simple example codes.

God bless for everyone that reads this topic, thank you

There are plenty of examples showing how to blink a LED. Just remember 38kHz is a 26microsecond cycle time.

sp. "want to"

This will get your 38KHz signal:

``````// This procedure sends a 38KHz pulse to the IRledPin
// for a certain # of microseconds. We'll use this whenever we need to send codes

void pulseIR(long microsecs) {
// we'll count down from the number of microseconds we are told to wait

cli();  // this turns off any background interrupts

while (microsecs > 0) {
// 38 kHz is about 13 microseconds high and 13 microseconds low
digitalWrite(IRledPin, HIGH);  // this takes about 3 microseconds to happen
delayMicroseconds(10);         // hang out for 10 microseconds
digitalWrite(IRledPin, LOW);   // this also takes about 3 microseconds
delayMicroseconds(10);         // hang out for 10 microseconds

// so 26 microseconds altogether
microsecs -= 26;
}

sei();  // this turns them back on
}
``````

Now all you have to do it tell it how to pulse. Below is the code I use to turn my heater on and off, your timing will be different. This should give you an idea on how to get your project up and running.

``````void SendPowerCode() {

pulseIR(1500);
delayMicroseconds(200);
pulseIR(1440);
delayMicroseconds(200);
pulseIR(600);
delayMicroseconds(1060);
pulseIR(1400);
delayMicroseconds(240);
pulseIR(1400);
delayMicroseconds(260);
pulseIR(560);
delayMicroseconds(1100);
pulseIR(540);
delayMicroseconds(1100);
pulseIR(540);
delayMicroseconds(1100);
pulseIR(540);
delayMicroseconds(1100);
pulseIR(520);
delayMicroseconds(1140);
pulseIR(520);
delayMicroseconds(1120);
pulseIR(1360);

delay(70); // wait 70 milliseconds before sending it again

pulseIR(1500);
delayMicroseconds(200);
pulseIR(1440);
delayMicroseconds(200);
pulseIR(600);
delayMicroseconds(1060);
pulseIR(1400);
delayMicroseconds(240);
pulseIR(1400);
delayMicroseconds(260);
pulseIR(560);
delayMicroseconds(1100);
pulseIR(540);
delayMicroseconds(1100);
pulseIR(540);
delayMicroseconds(1100);
pulseIR(540);
delayMicroseconds(1100);
pulseIR(520);
delayMicroseconds(1140);
pulseIR(520);
delayMicroseconds(1120);
pulseIR(1360);
}
``````

Kimc: .. IR communication, so I need to make 38kHz....

The mother lode of information for infrared remote control transmitting and receiving is Ken Sharriff's blog

The IRremote library has functions to create the signals and examples on how to use the functions. Rather than the rather inexact and jittery software method, transmission is accomplished by setting up a timer with the infrared LED drive signal coming from one of the timer's OCR pins. The carrier is pulsed by enabling and disabling the connection to the pin.

If you are able to use Timer 2 and Arduino Pin 3 to drive the LED, the Good News is that the IRremote library is ready for action. If for some reason you can not use Timer 2 and Pin 3 for this purpose, the the Less Than Spectacularly Good News is that you will have to modify the library code or use some other method. (The receiver can use any Arduino pin, but still uses Timer 2; the Pin restriction is for transmitting.)

In either case, in my opinion, the information on Ken's page (and the library code) is worth reading.

Regards,

Dave