Home Forums Sparkfun MP3 Shield Library Support Forum Adding an LED.. Reply To: Adding an LED..

#3499

I do not believe it may be as simple and straight forward as your attempt may be.

First electrically you don’t say what the schematic of it is. Note that the signal is AC and can be very small ranging from milli volts to 1vpp peak to peak. Note sure if you are isolating it through a cap. I believe that will need to be done, somewhere. The output amplifer of the 1053 is not isolated. And that will make it +/-. the minus will likely need to be clip the negative. So the ac signal will range from zero to positive peak, with a max of +1vp.

the above code should likely map to rescale the analog input to the output scale.

Also note about the Analog output; that it is really a duty cycle of a pulse. so if the signal was max of 1 vp, then that would be one fifth of the cycle. and noting even at max the signal is sinusoidal and only about a small portion is near peak.

The other aspect of concern is your update rate. there is no delay between samples and updates of the analog-write. So your code is constantly re-writing the duty cycle, way more time then an actual cycle. I believe the default cycle is around 490 hertz ish. So you may re-writing it hundreds of times per cycle. And that may be freaking it out. Not sure. Just a guess.

I would pass the audio input through a cap and low pass filter it. As to smooth/average out the audio energy and then sample that at 2 or 10 per second and then map (aka re-scale) that to a range that was visibly pleasing.