audio signal from headphones to trigger relay.

Hi!!!

I'll cut the chase and explain my problem.

This is my goal.

Audio signal from headphone jack will trigger the relay for about 30seconds.

When i call the phone, the audio signal will trigger the relay. Laptop cooler fan will be triggered by relay.
i wanted that even if i cancel the call the relay will stay on for 30seconds, then shuts down.

I have limited resources, i only have arduino, relay shield, audio jack and a phone.

What i accomplish:

Connect audio jack to phone.
Then i connect the wire going to gnd and analog input pin 0.

AnalogRead shows 0 when there is no music played then it shows 0-58 range when a song is played.

For the mean time, i use led pin13 on the board. It works, it only lights up if the audiosignal is > 0. So No light when no song is played, then it blinks when i played a song.

Main issue, led doesnt stay on for 5seconds, when i add delay, what changes is the frequency of time it reads, not the time led stays on.

If i use this configuration, the relay will go crazy turning on and off.

I wanted it to activate my laptop fan cooler for 30 seconds when i call.

I hope you could help me.
Thanks!!!!

Then i connect the wire going to gnd and analog input pin 0.

The Arduino can be damaged by the negative half of the AC audio waveform. The audio signal can be "damaged" (distorted) if you're trying to listen to it, and your phone might even get damaged.

You should bias the input (2 equal value resistors and a capacitor) with a circuit [u]like this[/u].

With the bias, you'll read ~512 with silence and the readings will bounce around above and below the bias value when audio is present. You'll need to tweak your logic, or at least adjust your trigger threshold.

If i use this configuration, the relay will go crazy turning on and off.

I wanted it to activate my laptop fan cooler for 30 seconds when i call.

Add a 30 second delay (30,000 milliseconds) after the relay is activated.