|In a frequency detector, you won't be turning on and off an LED, so you |would just test the input and increment a counter |(once or a number of times, depending on required noise immunity and |processor speed) for a period of time each time a |high is seen. You would repeat the process for the same amount of time and |counts, only decrementing the counter each time |a high is seen. The cycle rate of incrementing and decrementing would be |the target trequency. The number of samples and the |trigger threshold (count) would set the bandwidth. Noise would be present |both during the incrementing and decrementing and |would be cancelled (averaged) out. The problem you're apt to run into is that the phase of the input signal is unknown. Consequently, if you just use a single detector you'll get a signal that may be anywhere from full-value positive or full-value negative. There are two ways around this problem: [1] Use two or three dectors, whose phases are set either 90 or 120 degrees apart, and use a suitable weighting function to combine their results. [2] Use a reference frequency which is "off" by a known amount; this will cause the output of the detector to produce a wave whose frequency is the difference between the source and reference frequencies. For DTMF dection, [1] is the way to go although most TV's and FM radios use [2] in their tuning circuits.