Go Down

Topic: Read sound-frequency from 3.5mm jack ? (Read 3270 times) previous topic - next topic


Hi guys, I want to connect an audio source that produces sine-waves in different frequencies to my arduino and output/process those frequencies.
I guess I can't do that using pulseIn since the input is an analog signal. The device will be connected with a 3.5mm headphone jack. Any suggestions?

Thanks in advance !



you need an ADC and an FFT,

check - http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1286718155 - should help

or maybe - http://interface.khm.de/index.php/lab/experiments/arduino-frequency-counter-library/ - if you can make pulses of your sinus.

Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)


you need an ADC and an FFT

And maybe a side-order of DDS?
Per Arduino ad Astra


I guess I can't do that using pulseIn since the input is an analog signal.

Yes bung it through a digital input and it will look like a digital signal at the threshold of the input pin. Better still just put it through a transistor to "square it up" and use pulsein()


you mean just using a digital pin instead of an analog one?
how would i hook up that transistor to make it work that way?

thanks for helping


how would i hook up that transistor to make it work that way?

Signal to a resistor, other end to the base of a transistor.
Emitter to ground.
Collector to arduino input.
- Enable the internal pull up resistors by doing a digital write high just after you initialises the pin as input in the setup() function.
Remember pulsein will only measure the period of half the waveform.


ok, so if i hook up the input to a transistor and use the pulseIn fuction on the specific digital inputpin, then double the return value, i'll have the frequency?

what kind of resistor should I use? how many Ohms?


Can you tell us more about your signal? frequency and voltage?

Here is a circuit to solve a similar problem with some specific parameters (<20kHz frequency, 0.5V-1V bipolar range):


The Aussie Shield: breakout all 28 pins to quick-connect terminals


How does the next ciruit in your series
offset the input to 2.5?
With 10K & 30K resistors, why isn't the offset 5V*(10K/(10K+30K)) = 1.25V?
Should R3 have been 30K as well?
Designing & building electrical circuits for over 25 years.  Screw Shield for Mega/Due/Uno,  Bobuino with ATMega1284P, & other '328P & '1284P creations & offerings at  my website.


The positive terminal of the op-amp (pin 3) is set to 1.25V by the voltage divider R2 and R3. By negative feedback, the negative terminal (pin 2) is kept to the same voltage. Now R1 and R4 form a voltage divider:

1.25V = (Vout - Vin)*R1/(R1+R4) + Vin

When Vin is 0:

1.25V = Vout*R1/(R1+R4) = Vout*30k/(30k+30k) = 0.5Vout

so Vout = 1.25V/0.5 = 2.5V.

So it's not that the circuit offsets the input to 2.5V. It's that when the input is 0V, the output is 2.5V. When the input goes higher, the output goes below 2.5V, and when the input goes negative the output goes above 2.5V.

The Rugged Motor Driver: two H-bridges, more power than an L298, fully protected

Go Up