loading

I'd like to be able to detect a certian frequency using the Arduino. Anybody have an idea?

I'm brand new to the Arduino and I have the Duemilanove with the 328 processor. The incoming signal will be a multitude of low frequencies, all of them less than 20Hz.. I'd like to be able to select one and turn on a digital output. I'll be able to take care of things like input amplitude and bias etc. I would also like to find a good source for learning the programming language. Any help greatly appreciated.

sort by: active | newest | oldest
koensadza7 years ago
If you want to know how big the amplitude is, you should use the analog inputs and analogRead(pin). This will give you the amplitude (V) on a scale from 0 to 1023. You can put it in another scale with the map() function like: val = map(val, 0, 1023, newmin, newmax).

If you want to calculate the frequency of the wave, you can use the pulseIn() function. you use it like time = pulseIn(pin, value-to-watch-for).

More information can be found here: http://www.arduino.cc/en/Reference/PulseIn

Good luck!
Hi koensadza

Can you give a further example of how to detect a specific frequency with pulseIn, if possible? I've been looking at it after your post but it only seems to detect HIGH or LOW? Can it be used to pick up a specific freq?

Would I be correct in thinking that analogRead could be used to detect the amplitude along with pulseIn to detect the length of a tone; assuming a specific freq. couldn't be detected? Then, if the two conditions match, the combo could be used to trigger an event?

Thanks for your time!


gmoon7 years ago
Normally I'd recommend using a cheap 567 tone decoder chip. Here's an example schematic.

But 20Hz? It would be extremely difficult to differentiate such low frequencies. Maybe you could try to count the beats--run an opamp with the audio signal into the comparator of the AVR.
gmoon gmoon7 years ago
Actually, the 567 can lock on to frequencies as low as 0.01 Hz ... (just looked at the datasheet.)
dilandou7 years ago
Although i can't really give specifics on frequency detection (i'm still learning myself), I can point you towards good resources for learning Arduino.

http://arduino.cc/en/Tutorial/HomePage <-- A lot of example code.
http://www.ladyada.net/learn/arduino/ <-- Excellent for beginners.