I want to create a square wave of 38 KHz to be fed to an IR led.
One way is to make a pin high and low for 13 microseconds each. But I can not use that approach since this requires use of loop function.
My program is rather big and I would not be able to handle the complexities of doing other tasks as well as creating this 38 Khz wave both in loop() (if it can be done at all)
My question is, is there a way, by using a timer or something else to achieve this purpose? So that I can just start the timer in setup() and the pin in question will have 38Khz square as long as the program runs.
I am using ArduinoMEGA