Matt Marsh wrote: > Hi guys, > > For my second PIC project, I'm going to need to detect a button > being pressed on an IR remote control. I've done a small amount of > research on this and from what I've read I'm going to need to hook > up an IR receiver to one of the pins and then time how long pulses > last (and/or the gaps between them depending on the remote). Ok > So, in order to determine how long a pulse lasts I'm thinking that > I'm going to need to do something like: > > - loop waiting for pin to go high > - reset TMR0 > - loop waiting for pin to go low > - value in TMR0 now contains length of time of pulse That should work. The output of normal IR detectors is nicely processed and fairly easy to work with, just remember to ground the metal housing if there is one. A scope and a powered IR detector will show you everything you need to know. The output pin of the detector is normally idling at Vcc and drops to Vss when an appropriate carrier is detected. The detector strips the carrier from the signal and you only see the unmodulated pulses. IOW, it looks much like bursts of serial data bits to the micro. A burst (frame) may contain roughly 8-20 bits depending upon the system being used, the difference being that they are usually PWM or Manchester encoded instead of simply being present or missing to indicate a 0 or 1. > I just wanted to get some feedback whether I'm thinking of this in > the right way, or whether there is some other technique that is > generally used for timing pulses etc. The CCP feature is ideal for doing this without wasting allot of CPU cycles looping, plus it's more accurate/consistant. No one seems to have mentioned this yet, I'm kinda surprised. ;-) Have fun michael brown -- http://www.piclist.com hint: The list server can filter out subtopics (like ads or off topics) for you. See http://www.piclist.com/#topics