Well actually I am trying to generate a 38KHz pulse train using Arduino UNO board. The problem I am facing is in the delay. I have my IR LED connected to digital output pin 2. I am probing the IR led using a saleae logic analyzer to see how the pulses looks like after uploading my code on the Arduino board.
Problem I am facing is in the delay. What I want is a high pulse of 15.63us and a low pulse of 10.5us at the logic analyzer. So the period should be 26.13us. The delayfunction I am using in my code is delayMicroseconds.
When I checked the pulse width on the logic analyzer I observed that the high pulse width is increased to 21.4us and the low pulse width is increased to 16.2u. Which increases the period to 37.6u and reduce the frequency to 26.6KHz.
Please guide me about this delay. From where does this delay coming from and how can I reduce it .
delayMicroseconds takes an integer argument. Those decimals will be truncated. Furthermore, the resolution of delayMicroseconds is only 4us. Using delay of any flavor is not a good way to achieve what you want. I would suggest that you investigate using the hardware timers on the chip to get the sort of resolution you are after.
Can you tell me how can I get access to those timers and which tiemrs are the best fit in my case as I am new to Arduino platform.
It's not really a newbie topic. It's not as simple as a couple of lines of code. A considerable amount of thought and understanding needs to go into it. You should hit up google and find some tutorials on the timers (specifically timer 1) and try to learn a bit about how they work. Once you have the basics to work from then it will be much easier to put together your pulse train.
This will probably take a considerable amount of research on your part. Don't be intimidated, but it might take a day or two of reading and learning.