Hi guys,
I made an ir sensor manually by taking an ir photodiode, a resistor and an ir receiver. I connect it to a2 analog pin of my UNO r3. I can detect changes in the values as I obstruct the path. I have no part no. Data sheet for this thing. All I want is to modulate the pulse of the ir emitter at say 40khz. Can some one give me a code to achieve that? I saw some posts in Internet, talking about the 3 timers of at mega 328p, I can't make a head or tail =(. Just pls help me out guys.
Note:
I don't have that sharp ir emitter thing which is already sending pulses at 38khz. I want to achieve that thing manually.
Except that at these speeds the time spent in the calls to digitalWrite will mean it will toggle somewhat slower than 40kHz... You can try tuning the delay values, values of 6 and 7 seem to be best.
Thank you very much, chagrin. This was exactly what I was looking for.
Actually I saw the same Piece of code in an instructable page. But there wasn't sufficient info about the code. This link explains it all.
And MarkT, I was actually running a code similar to yours using digitalWrite.Thanks still, for giving me a more efficient version.