Sound to Frequency converter

Hey, I know this topic has been asked quite a few times already, but i can't seem to find something that works for what I'm looking to do. I want to be able to just take in audio using a microphone (KY-038) and somehow calculate or determine the frequency of the note being played (for instance, being able to play an A and having the arduino tell me it's ~440Hz). Most things that I have seen require using a different microphone or some sort of audio jack or other stuff. Is there a way that I can do what I looking to do with just the microphone I have and the arduino?

Thank you in advance!

People have made, or attempted to make, guitar tuners with the Arduino. As far as I can tell, most haven’t been successful. :frowning: As you may know, real-world sounds contain multiple frequencies. That’s why a guitar sounds different from a trumpet when playing the same note. And the fundamental frequency (which we perceive as pitch) isn’t always the most dominate (although it usually is).

I want to be able to just take in audio using a microphone (KY-038)

That’s not just a microphone, that’s a microphone board with a built-in preamp, right???

The analog output from the microphone-board can connect directly an analog Arduino input with no additional parts.


As a quick test run the Analog Read Serial Example. Most of these microphone boards are biased at 2.5V so you can read the negative half of the AC audio signal.

With the bias silence should read about 512. Quiet sounds should jump-around “randomly” near 512. Very loud sounds should jump-around “randomly” between about zero and 1023.

…If you don’t understand why it appears to be random, it’s because you are sampling a wave. See the [u]Audacity website[/u] for a little introduction to digital audio.

If you can “read sound”, your hardware is working and you can move-on to the software.


I’ve studied a little about frequency detection but I’ve never written any software for it…

If you have a pure tone (unlikely) you can measure the time between zero-crossings. Of course, the sample-rate has be known and you might want to average-out over several cycles. (There is some inaccuracy depending on the sample rate and you can’t find the exact zero crossing.)

[u]Autocorrelation[/u] may work best for finding the dominate tone.

The most common way to “analyze” audio is with [u]FFT[/u]. Basically, FFT tells you how much energy you have at each frequency (or in each frequency band or “bin”). …If most of your energy is at 430Hz, you’re out-of-tune. There is an FFT library for the Arduino.

There is also something called [u]FHT[/u] which is a little simpler (so it should run faster-better on the Arduino). And, there is also an FHT library for the Arduino.

Thank you a lot for the quick reply! I'll be honest, I'm really new to arduino coding and stuff so I'm honestly not sure if the microphone has a built in preamp, but I know it does have other parts attached.

I will look into the FFT and FHT stuff for the arduino. Do you know of any good tutorials that use these for me to look into?

Thanks again!

I’ll be honest, I’m really new to arduino coding and stuff

So let me be honest as well. This project is way outside your capabilities at the moment. It is an advanced project and it will not give reliable 100% results even when you do it right.

Do yourself a favour, learn the language and play about with other simpler projects to gain experience before you tackle this one.

We have seen it all before and without exception people who have tried this with your level of skill have always failed.

It also helps to have an oscilloscope when doing audio projects otherwise you are working blind.

For most sound projects the ADC of the Arduino is too slow (just under 10 kHz sampling frequency in default settings), and the memory far too limited to do the complex calculations needed to find the pitch of a certain sound.

There may be dedicated ICs out there that can take an analog signal and tell you the dominant frequency of the received sound.