Help with an arduino audio input project

I have chosen my project idea for to be a automatic guitar tuner from research and testing i have found that using a microphone to actually pick up the sound can be very unreliable therefore i was thinking on actually using a guitar lead to plug in from the guitar to the arduino board and i was wondering if this was possible and if so how can i do it?

You probably need a preamp but you can try it without one first.

You do need to [u]bias the input[/u] (2 equal-value resistors and a capacitor) because the Arduino can't accept the negative half of an AC audio waveform.

If you are connecting the guitar directly change the resistors to about 1 megohm (guitar pickups are high impedance). (You should be able to leave-out the 47nF capacitor). If you are using a preamp, resistor values between 10K and 100K are fine (but the two resistors must be equal).

With the bias the Arduino ADC should read about 512 with silence (half of the 1023 10-bit scale). With a signal the numbers will get bigger and smaller, centered around 512. You can subtract-out the bias in software if needed.

An electric guitar can put-out around 1 Volt into a high impedance, depending on how hard you pick it, how "hot" the pickup is, and the guitar's volume control setting. That should be enough signal if the voltage is sustained long enough.

So, I suggest you wire-up the bias circuit, connect the guitar, and run the [u]Analog Read Serial Sketch[/u] to see what kind of numbers you get.

If you can get readings that deviate from 512 by 100 or 200 and those numbers are sustained for a few seconds, you might be able to get by without a preamp.

It's fairly easy to make a preamp with an op-amp and 2 resistors (and maybe 2 or 3 capacitors), but the "basic default" op-amp circuit requires positive and negative power supplies* so that makes your power supply a little more complicated.

There are ways to power the op-amp from a single supply, and you can build the 2.5V bias into the op-amp circuit. If you are powering your op-amp from a single +5V supply, look for a "rail-to-rail" op-amp so you can take advantage of the full 0-5V swing.

...a automatic guitar tuner

From what I've read here on the forum, [u]autocorrelation[/u] works better than zero-crossing detection or FFT. (But that's about as far as my knowledge goes, so I can't help you with the actual pitch/frequency detection.)

  • I haven't made a guitar tuner, but my sound activated lighting effects use an op-amp circuit in font of the Arduino and it's powered from +/-12V. Then, I [u]protect[/u] the Arduino from any "unexpected" negative voltages, or voltages greater than +5V.

This is what I have used to get the audio just right in the arduino.. but im having difficulties as of right now analyzing that audio. If you find a solution to that let me know.

The arduino only reads 0 to 5v and audio usually goes - to + volts. using a DC offset at 2.5v you can get a 2.5v medium. The pot is used to keep the volts between 0 and 5. I will post an image of my schematic.

here is a good instructable on how to get audio into the arduino. keep in mind that she is using a dual power supply, one being for + voltage and the other being for - voltage. That kept me confused for a month. The schematic I have drawn out is not perfected but only uses one power supply, which is 12v but does not need to be.

Amandas instructable (good source).

That circuit is wrong in several places.

  1. the pot as drawn will do nothing, if it is a gain control then the wopiper needs connecting to one of the ends.
  2. the +Ve input of the op amp, what is that all about?

The circuit is working out just fine actually, I can see this with my oscilloscope. The pot is adjusting the volume. I know that its not the most ideal and am in the process of changing it up, but its working just fine. Im in a forum on another site with people that have been giving great suggestions on how to improve it and can read my schematic. Im not sure what you are asking when you question what the +Ve is all about.

The +vcc is referring to 12v for my circuit but it does not need to be 12 volts.

If your actual circuit is working then your schematic is wrong in that it does not reflect your actual circuit.

Hard to help if your schematic is telling lies.

What about my schematic is telling lies?

The wiper in the pot is not connected to anything. If that were true then it could not change the gain of the amplifier.

This is how its set up

variable resistor

This is how its set up

variable resistor

So what!.

That is not what you drew. If you were to draw that you would draw:-


In fact how you should wire this up is this:-

Remember Instructables are crap, do not try and learn stuff from them.

The second image looks like it would be just fine for my schematic. Instructables are as good as the people that make them. I have learned from them but I would say its a good idea to read the comments first. Amanda's instructables are interesting.

If christhomas1 wants to put audio into his arduino he now has a schematic and understands that the pot is drawn incorrectly, but thankfully we have corrected this. DVDdoug has given great information on how to get audio into the arduino and some ideas on how to do what he wants with that audio.