Go Down

Topic: cheap sound module: what version is this? (Read 37 times) previous topic - next topic


Nov 18, 2012, 06:26 am Last Edit: Nov 18, 2012, 04:36 pm by the-rebel-agent Reason: 1
Here you have a sample from the PAM8803 library:

Code: [Select]
Pam8803.h - Library to control a PAM8803 amplifier module.
Created by Diego J. Arevalo, November 18, 2012.
Released into the public domain.

#ifndef Pam8803_h
#define Pam8803_h

class Pam8803
  Pam8803(int resetPin, int volumeUpPin, int volumeDownPin);
  void reset();
  int volumeUp();
  int volumeDown();
  int setVolumeInHalf();
  int _gainSetting;
  int _resetPin;
  int _volumeUpPin;
  int _volumeDownPin;
  void setGainSetting(int volumePin);


Code: [Select]
Pam8803.cpp - Library to control a PAM8803 amplifier module.
Created by Diego J. Arevalo, November 18, 2012.
Released into the public domain.

#include "Arduino.h"
#include "Pam8803.h"

const int MIN_GAIN_SETTING = 1;
const int POWER_ON_GAIN_SETTING = 13;
const int MAX_GAIN_SETTING = 64;

Pam8803::Pam8803(int resetPin, int volumeUpPin, int volumeDownPin){
  pinMode(_resetPin, OUTPUT);
  pinMode(_volumeUpPin, OUTPUT);
  pinMode(_volumeDownPin, OUTPUT);
  digitalWrite(_resetPin, LOW);
  digitalWrite(_volumeUpPin, HIGH);
  digitalWrite(_volumeDownPin, HIGH);

void Pam8803::reset(){
  digitalWrite(_resetPin, LOW);
  digitalWrite(_resetPin, HIGH);

int Pam8803::volumeUp(){
  if (_gainSetting<MAX_GAIN_SETTING){
  return _gainSetting;

int Pam8803::volumeDown(){
  if (_gainSetting>MIN_GAIN_SETTING){
  return _gainSetting;

int Pam8803::setVolumeInHalf(){
  if (_gainSetting <= MAX_GAIN_SETTING/2) {
    while (_gainSetting <= MAX_GAIN_SETTING/2) {
    while (_gainSetting >= MAX_GAIN_SETTING/2) {
  return _gainSetting;

void Pam8803::setGainSetting(int volumePin){
  digitalWrite(volumePin, LOW);
  digitalWrite(volumePin, HIGH);

and It is working. void setVolumeInHalf is quite useful. Actually using my 8,9 and 10 pin for the amp.

Final library posted here:


You are right, your approach seems to be more simpler than mine. I will implement your solution solution ASAP and update my library. Thank you very much. That's why I love to share.


Thanks for taking care of this for me. About delay(30*35), It is cause of the time needed for the pam8803 to process a level up or down active low state. 3.5 clock cycles. Each clock cycle is about 30ms. You can read about it here:


There is a way to speed up the volume up/down process. 9.5 times + 2 ms for each level. I am planning to go that way to. But for small increments, 105ms don't sound that bad.

I also would love to continue talking about this here:

Don't want to go off-topic here.


I am feeding audio from a Sound module wtv020sd-mini which is PWM , to the mic Pins of My GSM Module Sim900, when I hear this sound on a a speaker although its not a high quality still its fair enough, but when I play the same voice and feed it to Sim900 mic and listen to it over a call its quality is very poor, there are alot of humming sounds and voice quality itself is also low.

I wanna use the module for voice response to callers , Is it all because of PWM output ? I used another module from ISD17150 and its voice quality is very nice even on the call.


There is a post about the quality of this audio module from a few month ago. Only suitable for voices or fx, no so much for music given the sampling allowed by this ad4 format.

Go Up