Show Posts
|
|
Pages: 1 2 [3] 4 5 ... 11
|
|
33
|
Using Arduino / Audio / Re: Arduino library for PAM8803 audio amplifier module
|
on: November 20, 2012, 01:28:57 pm
|
|
Latest lib could be downloaded from the very first post once you are logged in. About the PAM8803 retrolefty found, the price is great but the size is huge. In my laser gun project size and room are quite important. The one I bought, even If the a few bucks expensive, only measures 2cm x 2xm and could be powered from 3.3 up to 6 v.
|
|
|
|
|
40
|
Using Arduino / Audio / Arduino library for PAM8803 audio amplifier module
|
on: November 18, 2012, 10:34:05 am
|
PAM8803 audio amplifier module:  /* Example: Control a PAM8803 amplifier module from an Arduino board. Created by Diego J. Arevalo, November 20, 2012. Released into the public domain. */
#include <Pam8803.h>
int ampVolumeDownPin = 8; // The pin number of the volume down pin. int ampVolumeUpPin = 9; // The pin number of the volume up pin. int ampResetPin = 10; // The pin number of the reset pin.
/* Create an instance of the Pam8803 class. 1st parameter: Reset pin number. 2nd parameter: Volume Up pin number. 3rd parameter: Volume Down pin number. */
Pam8803 pam8803(ampResetPin, ampVolumeUpPin, ampVolumeDownPin);
void setup() { //Initializes the amplifier module. pam8803.reset(); //Set amplifier volumen in half output power. pam8803.setVolume(50); }
void loop() { };
Documentation: http://www.poweranalog.com/pdf/PAM8803.pdfUnzip Pam8803.zip into your library folder and that's all. There is a .volumeUp, .volumenDown that raise 1 level or decrement in 1 level the volume. You will have a getVolume to get the current level and setVolumen which accepts from 0 to 100 in percentage. Check Pam8803.h for more details or just ask me. Hope this helps. PD: Thanks robtillaart for your suggestions. They were considered and implemented.
|
|
|
|
|
41
|
Using Arduino / Audio / Re: cheap sound module: what version is this?
|
on: November 18, 2012, 12:26:20 am
|
Here you have a sample from the PAM8803 library: Pam8803.h: /* 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 { public: Pam8803(int resetPin, int volumeUpPin, int volumeDownPin); void reset(); int volumeUp(); int volumeDown(); int setVolumeInHalf(); private: int _gainSetting; int _resetPin; int _volumeUpPin; int _volumeDownPin; void setGainSetting(int volumePin); };
#endif Pam8803.cpp: /* 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){ _gainSetting=POWER_ON_GAIN_SETTING; _resetPin=resetPin; _volumeUpPin=volumeUpPin; _volumeDownPin=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){ setGainSetting(_volumeUpPin); _gainSetting++; } return _gainSetting; }
int Pam8803::volumeDown(){ if (_gainSetting>MIN_GAIN_SETTING){ setGainSetting(_volumeDownPin); _gainSetting--; } return _gainSetting; }
int Pam8803::setVolumeInHalf(){ if (_gainSetting <= MAX_GAIN_SETTING/2) { while (_gainSetting <= MAX_GAIN_SETTING/2) { volumeUp(); } } else{ while (_gainSetting >= MAX_GAIN_SETTING/2) { volumeDown(); } } return _gainSetting; }
void Pam8803::setGainSetting(int volumePin){ digitalWrite(volumePin, LOW); delay(30*3.5); 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: http://arduino.cc/forum/index.php/topic,133013.new.html#new
|
|
|
|
|
42
|
Using Arduino / Audio / Re: cheap sound module: what version is this?
|
on: November 16, 2012, 06:52:57 am
|
|
Hey guys, anyone using it at 5V? Cause I moved the soldered pin from 3.3 to 5 and could not get it to work. Quite erratically. I did not use any diode cause I believe they are soldered in the pcb board. Any idea?
|
|
|
|
|
45
|
Using Arduino / Audio / Re: cheap sound module: what version is this?
|
on: November 11, 2012, 08:13:30 pm
|
|
Well, only same cause they are using PAM8803, but two boards are quite different. It is huge compared with the one I bought. If you connect volume up to active low, from the very beginning, the amp starts at its higher level.
|
|
|
|
|