Go Down

### Topic: AC (guitar) signal to Analog Input (Read 1 time)previous topic - next topic

#### miro2424

##### Feb 09, 2008, 11:30 pmLast Edit: Feb 10, 2008, 04:50 am by miro2424 Reason: 1
Hello,

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?

#### Cheater

#1
##### Feb 09, 2008, 11:51 pm
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.

#### miro2424

#2
##### Feb 10, 2008, 12:46 am
No, I just want a value between 0 and 1023 depending on how hard I strum the strings.

#### jnguyen327

#3
##### Feb 10, 2008, 01:42 am
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.

#### Jaguarjoe

#4
##### Feb 10, 2008, 01:45 am
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.

#### MikMo

#5
##### Feb 11, 2008, 10:21 pm
Try to just pass the signal through a polarized (electrolytic) capacitor on the input pin.

Thats what many sound cards in PC's do.

#### cmpalmer

#6
##### Feb 11, 2008, 10:41 pmLast 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):

http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1202371284

http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1201637097

http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1202056662

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

Go Up

Please enter a valid email to subscribe

### Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

Arduino
via Egeo 16
Torino, 10131
Italy