Christmas Lights dance to music - trouble with getting earphone jack to work

We are working on the following project: http://www.hobbyist.co.nz/?q=dancing-lights

The setup looks ok and we can get the four LEDs lighting up, but when we plug in the Analog 0 wire and try to get them flashing to music nothing happens. Have tried a different headphone cable with no success. Also not sure about the white cable and where it is supposed to go. We have it from A0 to join directly with the orange and green cables.

If anyone has suggestions of what we can try next that would be appreciated. Would be good to get then going for NYears at least!

Try changing the 1st line of code to:

 #define soundpin A0

Your analog input is connected to pin A0, and that's what you should be reading.

Also, it's a bad idea to connect left & right channels together so I suggest you disconnect one channel.*

And, to prevent the negative half of the AC audio waveform from damaging the Arduino, the input should be [u]bias the input at 2.5V[/u]. With the input biased at 2.5V, silence will read about 512. You can subtract-out the bias in software (and then you can take the absolute value or throw-away the negative e values).

  • If you want to "get fancy" you can connect the left & right channels to two different analog pins. Then, you can sum the channels in software or make a stereo effect with different lights for the left & right channels, etc.

Thanks DVDoug.

Have tried altering first line of code, but no change.

We only have two wires in the headphone cable, so I guess only one channel. Or do you think we have the wrong cable?

Nothing wrong with the cable. You need to test your hardware, just write a program that prints out the value you are getting from the analogue input. It should be arround 512 with no sound and with sound he numbers should get increasingly above and below that number.

Your software already sends the analog readings to the serial monitor (to your computer if the USB is connected).

[u]Analog Read Serial Example[/u] tells you how to enable the Serial Monitor (just click the icon). You can also run the Analog Read Serial Example program with your existing hardware set-up.

Did you turn-up the volume all the way? Did you plug-in headphones to make sure you’re getting a signal? Did you try adjusting the sensitivity-pot in both directions?