0

I've seen some projects using PWM for playing audio files, and it seems like it needs an amplifier, otherwise the sound is very low.

I already made a project using a DFPlayer and PAM8403, but now I need more control over the files in the SD Card which is not supported by the DFPlayer library, so it seems like I need to use PWM and a SD Card module, instead of a separate audio module.

My questions are, can I simply connect the PWM output to the amplifier (PAM8403) and I will be able to control volume (using the programming language) and have a good quality sound?

0

Are you using a basic Arduino board (not I2S) and a sampling frequency of 8 kHz or 16 kHz? That could interfere with the default switching frequency of 260 kHz.

My suggestion is to use a low pass RC filter.
You might have to lower the signal level from the Arduino.
The PAM8403 requires a series capacitor and resistor at the input (those are probably already on the amplifier module).
In the end you probably need a voltage divider with a capacitor to ground for each channel.

I don't know if your PWM library has volume control. The TMRh20 has a function to set the volume.

The overall quality will be reasonable, but not very good. There are MP3 shields that can play mp3 files from a SD memory card. Those have better quality.

[ADDED]
I think I have misunderstood your question. Sorry. I'm still not sure that I understand your question now.

Wiki of DFPlayer Mini: DFRobot:DFPlayer Mini
Code on Github for DFPlayer Mini: Github:DFPlayer Mini
The PAM8403 has no volume control, you need to adjust the audio signal that is going to the PAM8403 module.
The DFPlayer Mini code has functions for volume, volumeUp, volumeDown and readVolume. However, it does not seem to have a function to select a specific file.

The Adafruit Music Maker shield is in two versions, one has an amplifier onboard: Adafruit:Music Maker MP3 Shield for Arduino w/3W Stereo Amp - v1.0. With that shield, you can play a file by its name. It can also set the volume. I suppose that is what you want ?

| improve this answer | |
  • I already have a project running with DFPlayer, but now I need to have control over the fles in the SDCard and it seems like none of the mp3 modules provides that. I can chose any board. Currently the DFPlayer project was made with a nodemcu – Valdir Jun 25 '17 at 14:50
  • @Valdir, I have added a [ADDED] section. In my opinion, every "normal" mp3 player module can select a file, only the very cheap ones can only play the next one, but not a specific file. – Jot Jun 26 '17 at 5:22
  • Note that if using the TMRh20 library, which uses raw PWM to generate audio, the correct "audio amplifier" to use to drive the speaker is a DC motor driver (H bridge), such as one from Pololu. – Gabriel Staples Aug 25 at 1:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.