Go Down

Topic: Read a freqency from an analog pin (Read 3 times) previous topic - next topic


OK.I want to use a library, or a function wich can read a frequency. After reading i want to separe in 2 frequences with if conditional. That is all.  :P


I don't want to read volume. I have found this : http://tushev.org/articles/electronics/43-measuring-frequency-with-arduino
Can make for me an example code with this library? Thanks in advanced.


I think this should be possible if there is a single frequency or a dominant frequency, especially at low frequencies.  At higher frequencies, processor speed could be an issue...   And, frequency measurement can just be "flaky", even with a proper frequency counter.   Often you have to manually adjust a threshold control to get a good-stable reading.

Normally, you'd measure the time betwen zero-crossings (i.e  When the waveform goes from positive to negative or vice-versa).  Since the Arduino can't accept negative input, you'd have to bias the input (i.e. 2.5V) and use the effective zero-crossing (bias-crossing) instead of the actual zero crossing.   You need to allow for noise, so you'd have to look for values slightly above and below the zero-crossing (perhaps calibrating to a percentage of the peak), and you'd have to ignore low signal levels.

You should probably "isolate" your time-measurement from your frequency calculation and other code.  In other words, run a tight time-measurement loop (perhaps several times to take an average) and then break the loop and process your data.

If you are analyzing complex sounds with more than one frequency component (just about anything other than a test-tone,) you'll need to look into FFT/DFT (quite a bit more mathematically complex).


Can make for me an example code with this library?

When is our homework due?


I don't need the full code. I want only a line , wich read frequency...
Please help.  =(

Go Up