Having Trouble with Output Voltage.

I'll start by saying I'm completely new to the Arduino and circuitry in general but have a project I need to complete for work and was hoping I could get some guidance on my current roadblock. I'm looking to take an error sound generated from a computer and use the 3.5mm output from the computer as an input into the Arduino; then perform an output that would send a signal to a controller on a conveyor to shut down.

According to one of our electrical guys, the controller is older and we're unable to set a minimum threshold for what voltage would trigger the shut down. Initially I thought I could put together a VU meter from a tutorial and then modify it to take an output from one of the last lights to use as my signal wire to the controller. After setting up the meter though I'm measuring around 0.1v at the end of the 200 ohm resistors. When a sound is played the voltage jumps up to about 1v like I expect but I still need to clear any voltage off the line when a sound is not being generated.

I've put together the VU meter from this tutorial: http://arduinoarts.com/2011/08/uv-meter/

Here is a drawing of how I have everything laid out.

Below is the code I have loaded into the Arduino right now, taken from the tutorial I linked above:

/* UV Meter (via Headphone Output)

int pinArray[] = {2, 3, 4, 5, 6, 7};
int count = 0;
int timer = 10;
int sensorValue = 0;
int countmax;
int knockSensor = 5;
int val = 0;
int statePin = LOW;
int THRESHOLD = 100;

void setup(){
for (count=0;count<6;count++) {
pinMode(pinArray[count], OUTPUT);
}
}
void loop() {
sensorValue = analogRead(knockSensor);
if (sensorValue < 100) {
countmax=1;
}
else if (sensorValue < 300) {
countmax = 2;
}
else if (sensorValue < 350) {
countmax = 3;
}
else if (sensorValue < 400) {
countmax = 4;
}
else if (sensorValue < 450) {
countmax = 5;
}
else if (sensorValue < 500) {
countmax = 6;
}
for (count=0;count <= countmax;count++) {
digitalWrite(pinArray[count-1], HIGH);
}
for (count=6;count > countmax;count--) {
digitalWrite(pinArray[count-1], LOW);
}
}

From what I've tested, this voltage is present even when I don't have the input from the 3.5mm hooked up to the board. Do you all have any recommendations on what I could do to filter out that small amount of voltage I'm picking up? Would a different size resistor take care of this, or am I looking at scrapping what I've got and starting over with a different design and code?

Any help or advice is greatly appreciated.

Thanks

Since audio is AC you generally need to [u]bias the input[/u] with two equal-value resistors and a capacitor. (You can ignore the 47nF capacitor.) The Arduino can be damaged by the negative half of the audio waveform and the audio signal can be "damaged" (distorted) also.

With the input biased at 2.5V, the Arduino's ADC will read about 512 with silence, and audio signals will go above and below that reading. You can subtract-out the bias in software if it makes things easier.

Since audio is a wave and you're reading at random/unknown points along the wave your readings will jump-around a lot, but you should see bigger positive & negative numbers with louder sounds (after subtracting the bias).

Instead of making a VU meter, try running the [u]Analog Read Serial Example[/u] so you can see what kind of numbers you're getting.

You know why we hate fritzing diagrams here? Mainly because people can't use the right components and we have to end up guessing what the hell things are.
So what is that on the right, the thing that looks like a speaker? Is it sending audio into the Arduino? If so you are subjecting the analogue input pin to negative voltages and you will damage it.

A VU meter needs to have an envelope follower on the front end to smooth and rectify the audio. You don't want the circuit that doug suggested because you don't want to read the audio signal, just the envelope.

Envelope follower.jpg

Use code tags not quote tags for that awful code.

From what I've tested, this voltage is present even when I don't have the input from the 3.5mm hooked up to the board.

Yes you will because the input is floating. Connect it to ground and you won't measure voltage on the output from those pins.

Thanks for the replies, and my apologies for the fritzing diagram. I performed a quick google search and that's what got several hits. Yes that input is coming from a speaker output on a PC. I'll retest my ground connections in the morning when I get in and see if I can pick up the resistor and capacitor you have shown in the diagram.

and see if I can pick up the resistor and capacitor you have shown in the diagram.

Don't forget the diode.