Go Down

Topic: Arduino Uno Guitar Tuner (Read 1 time) previous topic - next topic

Maclaurin

I've just recently gotten the Uno and I'm completely new to programming and electronics. I've searched around the forums and found some threads similar to my question but they're a bit too complicated for me to understand. I'm not really asking for direct help, I just want to know if what I wish to do is possible.

I'd like to create a guitar tuner. I want to be able to plug the guitar jack straight into one of the analog pins in the Uno and have the Arduino log the input frequencies from the plucked strings on a guitar. I assume I'd have to sample the frequency over a few seconds and average it to get any specific result. Afterward I'd like to make an If/Then statement to send to the digital pins that will output High to LEDs. I want to have 9 LEDs and based on the frequency input certain LEDs will light up to show what musical note is being played. I think I could set up a 3x3 array of LEDs and have them light up to show the letter of the note. For example if the frequency from the guitar is 440hz then the LEDs that make the shape of an A will light up.

Will I be able to do such a project with just the Arduino Uno and possibly an OP Amp to boost the signal from the guitar?

HazardsMind

Yea but it will take a lot of...fine tuning.  :smiley-yell:

You'll want to have it as an analog input from the guitar, not digital.
My GitHub:
https://github.com/AndrewMascolo?tab=repositories

winner10920

Actually digital will be much easier, in the meaning of just a square wave, you can use that(after some conditioning to keep it in the 0-5v range) and one of the hardware timers to very accuratley gauge the frequency
and why not use a alphanumeric led display to show the note, or even an lcd screen(quite cheap on ebay like 3$), then you can show the exact frequency and how far it is off, maybe even use the bottom row to show a line which would move left or right from center to show which way its off

Maclaurin

Well wouldn't the input frequency from the guitar be a sine wave?

Would I basically need to take the input and run that through an amplifier and then use an RC filter to keep the signal from 0v to 5v? Then I imagine I could use the frequency counter libraries or pulse count to log the frequency over a set period of time?

The reason I want to use LEDs is just to have practice with writing code and routing the signals to the different pins on the Arduino.

wmassano

The output of a guitar string is not a simple sine wave, but a sum of many harmonics. You would have to suppress all but the fundamental (the harmonics are lower in intensity) and then condition it. Perhaps using a flipflop as a one shot triggering on the positive pulses.

retrolefty

#5
Nov 19, 2012, 01:52 am Last Edit: Nov 19, 2012, 01:55 am by retrolefty Reason: 1

Well wouldn't the input frequency from the guitar be a sine wave?

Would I basically need to take the input and run that through an amplifier and then use an RC filter to keep the signal from 0v to 5v? Then I imagine I could use the frequency counter libraries or pulse count to log the frequency over a set period of time?

The reason I want to use LEDs is just to have practice with writing code and routing the signals to the different pins on the Arduino.


If I was doing it I would wire the guitar signal via series coupling capacitor to a +5 volt op-amp comparator chip, they are cheap and in small 8 pin packages and would generate a good digital 5 volt square wave representation of the fundamental frequency of the signal with no other filtering required. Then the output of the comparator would wire directly to a digital input pin and then use a frequency counter software function to measure the frequency of the signal. This will be much better then trying to handle the signal as a analog signal (need filtering and amplification most likely) where you would need a much more complex FFT software algorithm to extract the frequency.

Lefty

Maclaurin

I believe I understand the comparator idea. Basically the guitar input goes through a capacitor that gives will give an AC output. This output would be put into the comparator on the voltage input pin with some other voltage in the voltage reference pin. I suppose the voltage reference would have to be very close to the to the max amplitude of the guitar input? Or would I rather use the frequency counter/pulse counter function to recognize the rising edge each time the input voltage was higher than the reference voltage? I'm sorry if I'm not using correct termanology, but everyone is helping tremendously. Thank you!

retrolefty


I believe I understand the comparator idea. Basically the guitar input goes through a capacitor that gives will give an AC output. This output would be put into the comparator on the voltage input pin with some other voltage in the voltage reference pin. I suppose the voltage reference would have to be very close to the to the max amplitude of the guitar input?

No, just some small stable voltage level above the noise level of a no signal condition. The comparitor will switch at each 'zero crossing + reference' as in this simplified circuit (also not showing the series connected coupling cap for the signal. Then it's simple a matter of counting the frequency in software which is much simpler then trying to extract the frequency using analog reading samples. 

http://www.piclist.com/images/www/hobby_elec/gif/dance2321.gif


Or would I rather use the frequency counter/pulse counter function to recognize the rising edge each time the input voltage was higher than the reference voltage? I'm sorry if I'm not using correct termanology, but everyone is helping tremendously. Thank you!

Maclaurin

#8
Nov 19, 2012, 06:33 am Last Edit: Nov 19, 2012, 06:53 am by Maclaurin Reason: 1
Haha, I was just brushing my teeth and it dawned on me that that is how I would do it, then I come back and you've already answered the question! Thank you so much!

Now all I really have to worry about is what the input wave is going to look like and how to retrieve the fundamental frequency of the wave. The code should be pretty simple as well. You, sir, are a genius!

winner10920

You don't need to worry really how it looks like, just use a potentiometer for the reference voltage on the comparator and adjust till you get stable square wave

retrolefty


Haha, I was just brushing my teeth and it dawned on me that that is how I would do it, then I come back and you've already answered the question! Thank you so much!

Now all I really have to worry about is what the input wave is going to look like and how to retrieve the fundamental frequency of the wave. The code should be pretty simple as well. You, sir, are a genius!


As long as you are only picking a single string the signal will be predominately a sine wave with some harmonic content, but with the proper bias adjustment to the comparator you should get a nice clean square wave output that is only the fundemental frequency of the string. Now start playing cords and all bets are off as the signal will be quite complex and the square waves generated will be of meaningless information.

Lefty

Go Up