I am trying to use a digital potentiometer for volume control with my Arduino Uno.
I am using the LM386 amplifier with the above setup. The mechanical 10K pot has been replaced with a 10K AD5245 Digital pot.
Here is how the pot is wired up:
A = Pin for of Arduino Uno
B = GND
W = Pin 3 of the Amplifier
SDA = A4
SCL = A5
AD0 = GND
Vdd = 5V (Arduino)
GND = GND
I tested out a simple program to check the adjustments of volume and here is the code:
tone(4, 261); //Output tone on pin 4 and 261Hz
Wire.beginTransmission(44); // transmit to device #44 (0x2c)
Wire.write(byte(0x00)); // sends instruction byte
Wire.write(val); // sends potentiometer value byte
Wire.endTransmission(); // stop transmitting
val++; // increment value
if(val == 255)
{
val = 0; // start over from lowest value
}
delay(1000);
It increases resistance until the value 255 is reached. After testing the code out, the 4th or 5th value is equal to max volume. When using a mechanical linear pot, the volume can be adjust in the first half a turn before reaching maximum volume. Am I doing anything wrong here? Any advice much appreciated!