The Arduino Guitar Tuner I Didn't Build

By Ari Dubinski

I was not the first person who tried to build an Arduino guitar tuner, nor was I the first person to fail. That doesn't mean, however, it hurts any less. I started the project with a full head of steam but this is not a success story.

I began by combining Amanda Ghassaei's code for Audio-In and Frequency Detection for the Arduino. I found both on her Instructables page.

Man found the trouble I created a gain circuit for a ¼ inch input that would output an analog signal between 0V to 5V to the A0 pin of the Arduino Uno. The code would work by receiving the analog input and executing an Interrupt Service Routine (ISR). The code had some cool subtleties, like checking for clipping and sending an index number (between 0 and 255), which was then analyzed as amplitude. Timer values are also collected and are used for the period values.

Dividing the period values and fixed sample rate gave me a useable frequency. Then I converted the frequency value into an index number which would correspond with a named note. For example, 82Hz corresponds to the 28th value, which then signals the matrix to output the E2 note. The ISR is called every time it detects an input signal and the duration between held notes would be decided by polling. This ultimately wouldn't be the final design, because it left some holes. I still had to deal with issues like note accuracy and decreasing the noise generated from the input device. Noise is a big issue because it is present with every pitch and it would sometimes even impact the correct value of the pitch.

Like the 3M designer who failed to create glue that would stick, I wondered what I could do with what I had created. I hoped that I too might come up with the next Post-It Note. So, instead of a guitar tuner, I decided what I really needed in my life was a SIMON game for the guitar. No longer would I have to worry about the precision of a played note, but would instead output a randomly generated sequence of notes where the user would have to input the same sequence either by signing or by playing the guitar. This would eliminate the need to develop an accurate guitar tuner and would instead allow me to focus on the noise issue at hand.

Finally I was making some progress, but then it occurred to me there was another issue. Sometimes the game would output two notes of the same pitch sequentially, such as B-G-A-A. The game would then need to distinguish between the two As the user would input. Again, I turned to delays but it couldn't really solve my problem. There was something wrong with using delays throughout the whole project and I was now beginning to notice that using delays couldn't be the final answer to discerning frequencies between each other. When challenges present themselves, serious engineers overcome those problems and laugh at those lesser mortals unable to conquer technological challenges.

Thus, my solution would lie with Signal Processing Theory. I turned to Fourier Transforms and decided that a Fast Fourier Transform algorithm would be the key to eliminating noise from my input signal. To test the accuracy of the FFT, I used a built-in feature of Excel called Fourier Analysis. I would input a sample of 256 or 128 data points gathered from the Arduino's Frequency Detection algorithm and would store them along with their sampling rate in Excel. The program would then analyze the points.

Brilliant! Right? I thought so, but it would often give me a wrong fundamental frequency which would differ from the intended frequency. This is where I got stuck, because I couldn't find a working solution to the FFT. I thought that by using an FFT I would only see the intended pitch, but instead I noticed either a wrong frequency being detected or sometimes multiple wrong frequencies being detected with equal magnitude.

My problem lies with getting a precise input into my tuner and SIMON game. If I could eliminate the noise generated from the magnetic presence of electric pickups, I could eventually move on.

So instead of chalking this up as a failure, I like to think of this project as still in the prototype phase while I look for a better solution. I would like to increase the reading speed from the user to the Arduino and I would also like to get clear and consistent results. And when I finally accomplish my goal, I won't tell anyone about the struggles I had along the way.


SchematicGuitar Tuner Schmatic with LED Matrtix Output

Guitar Frets and Notes vs Frequencies

For further reading, check out the links below:
Amanda's Instructable: Arduino Frequency Detection
Arduino Audio Input
FFT in C
Numerical Recipes in C


Ari currently attends Cal Poly, San Luis Obispo and is pursuing a degree in Electrical Engineering. He teamed up with Jameco to accelerate his learning, as well as lend a helping hand to a major electronics distributor. His interests include shredding on the guitar, electronics and music production.

If you have an electronics story or project you'd like to share, please email [email protected].