Go Down

Topic: AC (guitar) signal to Analog Input (Read 898 times) previous topic - next topic


Feb 09, 2008, 11:30 pm Last Edit: Feb 10, 2008, 04:50 am by miro2424 Reason: 1

Can anyone tell me how could I input an AC (guitar) signal into Arduino Analog Input so when strumming the guitar I would see stable data from 0 to 1024 depending on how hard I strum the strings.

Thank you.

PS. I tried to use an Opamp circuit to amplify the signal but I still get an 'AC' data kind of input. Maybe what I need is to write a program that would somehow smooth the data. Does anyone have any ideas or information I could read?


So you want a value between 0 and 1023 depending what note your playing?

Very difficult. You need to convert the waveform to something usable.
I dont know how you would do it.


No, I just want a value between 0 and 1023 depending on how hard I strum the strings.


Well, if you sample the signal from the guitar fast enough you should come up with the wave form. I don't know what the frequency of the guitar is but I think human hearing range is up to about 22 kHz. In that case you need to sample at least 44 kHz fast which is possible with the 16 MHz ATmega168 chip. So what you could do is save the last sample. Then get the current sample and subtract the last sample from the current sample to find the delta. Err, also save the last delta. If you notice the "delta" change signs then you know that the sinusoidal wave has just passed a peak or trough? If that's the case then you can take the sample there as the amplitude of the wave. However, this assumes a sinusoidal wave which I'm guessing might not be the case. See if you can just log the data and plot it to see what the wave looks like. If you're crazy enough you could run a discrete FFT... just an idea. Or if anything you could just keep a running max or min of the samples in the past 100 samples or something and use that as your amplitude. Bah, I just realized that the Arduino can't really pick up the negative voltages since the ADC goes from 0V to 5V. Well, you could still do a similar analysis I think.


You would need to rectify that AC signal into a DC signal that the ADC will be able to work with. Then the DC signal will vary in amplitude according to how loudly you strum the guitar.


Try to just pass the signal through a polarized (electrolytic) capacitor on the input pin.

Thats what many sound cards in PC's do.


Feb 11, 2008, 10:41 pm Last Edit: Feb 11, 2008, 10:41 pm by cmpalmer Reason: 1
You might also want to check out these threads - they are all doing something very similar (trying to read volume/sound intensity via the analog pins):




It sounds like once we get some solid solutions, this should go in a FAQ or in the Playground...

Go Up