Is there a way of detecting audio (from a smartphone headphone jack) using a digital pin on Arduino? I don't need to analyse the signal in any way, I just want to know is there audio or silence. The audio will always be the same - a 10Hz test tone. Any searching I've done is using an analog pin but all of mine are being used and as I only need an on/off signal it seems sensible to use a digital pin. With the phone at full volume and the audio going through a diode, I'm seeing 0.3Vdc on an oscilloscope (though only half the signal, but that should be good enough) so I believe it should just be a case of stepping this up to 3+V for an arduino digital pin to see it as High? I've experimented with an LM747 op-amp but unsuccessfully, I just get a constant voltage regardless of audio playing or not
How exactly do you connect and use it? Make it work as a comparator.
-
Google voltage comparator.
-
An LMV321 is a reasonable single supply rail to rail opamp to use.
EDIT
- Also, look at using the TL331 comparator.
Search for a "voltage doubler" or "voltage trippler" circuit.
You shouldn't put AC audio into the Arduino because it can be damaged by negative voltages, although -0.3V is OK The specs say -0.5V to +Vcc. The Arduino could be damaged, the audio circuit could be damaged, or the audio signal could be "damaged" (distorted).
On a regular Arduino digital high is 3V or more and low is 1.5V or less. (In-between is undefined.)
With analog you can set your own threshold in software.
Here are 2 audio input circuits that can be used with an analog input:
This one biases the signal at 2.5V and the audio rides on top of the bias.
This one "kills" the negative half of the signal.
Or with an op-amp you can use a Peak Detector which can optionally be built with gain. With gain you could use it with a digital input.
flashko - 12vdc supply to V+ & V- and tried both as inverting and non-inverting with suitable resistor values for the gain I need but neither configuration worked - really not sure why.
LarryD - Thanks, just knowing the term to search in Google is a good start!
Paul_KD7HB - I've only got 2 capacitors & 2 diodes at my disposal at the moment, but just built a voltage doubler and am getting 1.3Vdc from my audio signal so that's a good start! Thank you for that
DVDdoug - Yes, I found some old posts regarding switching voltages hence aiming for 3V minimum and also learned not to put AC directly onto an arduino pin! I realise using an analog pin I could set my own threshold value for switching.
I will keep experimenting with the tips you've all given - thank you all!
Just wanted to close this thread off for anyone who stumbles across it in the future! I went with Paul_KD7HB's suggestion and after finding more diodes and capacitors have made myself a "voltage quintupler" circuit which is giving me a nice healthy 3.5Vdc. Have tested it using the Button example sketch and the led responds to the test tone (I actually switched to a 1kHz tone downloaded from here) I also had to use a 1MΩ pull-down resistor to 0V as lower resistance values wouldn't allow the pin to go High which I assume is because the voltage is quite weak? Only discovered this after disconnecting my multimeter from the circuit and noticed that it no longer worked! So the internal resistance of the meter was performing the job of pulling down to 0V.
This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.