enjoyneering / DFPlayer

Small and fast Arduino library for DFPlayer Mini MP3 Player
GNU General Public License v3.0
40 stars 9 forks source link

Volume control not working #8

Closed stephandobri closed 1 year ago

stephandobri commented 1 year ago

Thanks for creating this library! I've been unable to get the official DF Robot library to work but this one does. I did run into an issue initially with not being able to control the volume but found a fix for it.

In the .h and .cpp files the setVolume command is defined as:

void setVolume(uint8_t volume);

whereas the DF Robot library defines it as:

void setVolume(uint16_t volume);

Changing the setVolume to be uin16_t in the .h and .cpp files for this library allowed me to control the volume.

enjoyneering commented 1 year ago

The uint16_t is overkilling, because the volume range is 0..30, which is closer to uint8_t (0..255). On older microcontrollers this saves RAM and flash memory. Just change the size of the volume variable in your sketch to uint8_t.