I have a project I'm working on where I am going to trigger sound effects from a dfplayer mp3 player module. The audio is going to be fed to a speaker, possibly with a small amplifier (if it needs to be louder).
But I would also like to see if there is a way to use the amplitude of whatever sound is coming out to trigger other effects. (such as an analog led 'fade/dimmer' effect and possibly moving a servo to open-close an animatronic's mouth when playing a file with words)
I'm not entirely certain what the output of the dfplayer is or how much juice is running out of it. I wouldn't want to damage an input pin. Can anyone let me know if this is possible and how to go about getting an analog value (0-255) from an audio source such as the dfplayer?
Can anyone let me know if this is possible and how to go about getting an analog value (0-255) from an audio source such as the dfplayer?
The Arduino's analog-to-digital is 10-bits and it reads 0-1023.
See the [u]Analog Read Serial Example[/u].
You'll need to bias the input (see attached schematic) because the Arduino can't read the negative half of the audio waveform. The Arduino can be damaged by negative voltages an/or the negative half of the audio waveform may be damaged/distorted. As long as the DF player is running from 5V, it can't go above +5V. (And it only goes negative because there is probably an output capacitor to filter-out the "DC component".)
With the bias, silence will read about 512. You can optionally subtract-out the bias and either ignore the negative values or take the absolute values.