Simple Volume Control

You could attach a servo to the shaft of the 1Mohm potentiometer, and use the Arduino to drive servo.
Or you could use a digital potentiometer in place of the 1Mohm potentiometer, controlled by the Arduino.

You need to attach something to your arduino to do this, you can't do it directly.
The first suggestion of a digital pot sounds good to me.

Thanks to reply!

Can anybody sugests me an digital potentimeter solution on the web what working with arduino?

You could always google
Digital pot arduino
But then what do I know?

In normal case I use a simple 1 MOhm potentiometer for this job. I would like to replace the potentiometer with arduino

No... Not 1 Meg... Not if your volume control is in-between the audio player and your headphones. Most headphones are around 32 - 64 ohms. Some "high-impedance" headphones are 600 ohms. A 100 ohm pot is more like it. :wink:

A volume control on the line-level input-side of a headphone amp would be in the range of 10k - 100k ohms. A pot on a guitar amp input might be 1M.

I encourage you to experiment with a regular (mechanical) pot (or a pair for stereo) before you buy a digital pot.

Also, volume controls are not regular linear pots. They have an "audio taper" (approximately logarithimic). You will need to program that into your firmware (sketch), or else "half-way" will sound too loud... But that's something you can experiment with once you get it working.

Can anybody sugests me an digital potentimeter solution on the web what working with arduino?

Thank you for all suggestion.

Now i bought the arduino and ad5206 100Kohm digitalpot.
How can I connect the line signal to the ic? Need anythying between the ic and the audio source line signal?

Sorry but I'm an amateur in the electronics, I'm just a programmer. :astonished:

How can I connect the line signal to the ic?

To pin A1. Pin B1 to signal ground and pin W1 to the input of the amplifier.

Make sure that your signal voltages are within the range of the power supply of the chip.

Why must to connect the signal ground all chanel pot??? On a simple potentiometer I must to connect only the signal, or not?

On a simple potentiometer I must to connect only the signal, or not?

No idea what that means can you use some other words to try and express this please.

You have to connect the ground to a pot to get a potential divider action.

Hy All!

Now I built my Arduino Shield but My SPI Pins are reserving by rfm12b transreciver.
Hoe can I use the digital pot from other digital pins?
I soldered the
CLK to pin 7
SDI to pin 6
CS to pin 5

My idea is I write my own library what looks like the SPI library
Or any other Idea?

Hmm...

Well first of all you can have more than one device use the SPI bus, you just use a different CS pin for each device but MOSI, MISO, and SCK/CLK, are shared between all devices, then you can use SPI.transfer() etc. like normal.

But if you've already soldered the pins then you're stuck with what you have. In that case you can Google things like "arduino bit bang SPI" or "arduino manual SPI" if you don't want to write your own library from scratch. Here's a good one:

Good luck!

Thank you for your answer.
I will check yous suggested link, but this is a protoshield with cu wire on pins, so if that easier I resoldering my shield.

Can you offer a link or a tutorial about the shared spi and spi.transfer?

If you Google for something like "arduino multiple spi devices" you'll find a lot of hits. Here's one:

Each slave chip will have its own Arduino pin that goes to its Chip Select pin. All slave chips will share the Arduino MOSI, MISO, and SCK pins. You just set each chips CS pin to low, use SPI.transfer(), then set it back to high:

digitalWrite(chip1_cs_pin, LOW);
SPI.transfer(chip1data);
digitalWrite(chip1_cs_pin, HIGH);

digitalWrite(chip2_cs_pin, LOW);
SPI.transfer(chip2data);
digitalWrite(chip2_cs_pin, HIGH);

Thanks a lot!

Now I resoldering my shield, now I can control the IC.
But this only works on 0 and 255 all other value have a louder or quiter but the quality is criticaly :S
On the value 255 the sound quality is perfect, but all other value is sound makes crackling..
I don't understand what is the problem

Here is my code (based on spi by hand):
int SS1 = 5;
int CLK = 7;
int MOUT = 6;

byte ch1 = B00010001;
byte ch2 = B00010011;
byte ch3 = B00010010;
byte ch4 = B00010000;
byte ch5 = B00010101;
byte ch6 = B00010100;

byte work = B00000000;

void setup() {
pinMode(SS1, OUTPUT);
pinMode(CLK, OUTPUT);
pinMode(MOUT, OUTPUT);
digitalWrite(SS1, HIGH);
spi_out(SS1, ch1, 255);
spi_out(SS1, ch2, 255);
spi_out(SS1, ch3, 255);
spi_out(SS1, ch4, 255);
spi_out(SS1, ch5, 255);
spi_out(SS1, ch6, 255);
}

void spi_transfer(byte working) {
for(int i = 1; i <= 8; i++) {
if (working > 127) {
digitalWrite (MOUT,HIGH);
} else {
digitalWrite (MOUT, LOW);
}
digitalWrite (CLK,HIGH);
working = working << 1;
digitalWrite(CLK,LOW);
}
}

void spi_out(int SS, byte cmd_byte, byte data_byte) {
digitalWrite (SS, LOW);
work = cmd_byte;
spi_transfer(work);
work = data_byte;
spi_transfer(work);
digitalWrite(SS, HIGH);
}

void loop () {

}

when arduino power of the sound volume state go to middle posistion and the quality is so bad again. :frowning:

Does anybody can tell me why has the volume control a bad quality when I try to adjust between 0 to 255???
Help me please!

I soldered all A pin to sound signal all B pin the signal gnd and W pins go to the amplifier.

I tried to swap the signal and ground pins, a tried to swap the spi pins but always the same.
On 0% and 100% the sound quality is perfect all other state has so bad quality :frowning:

Your problem is probably with your circuit layout, and lack of decoupling between the analogue circuits and digital circuits.
You should use a star ground system. That is one where the ground lines are not chained but all connected to a single point.
Also short leads are important, and don't route analogue signals close to digital ones.

Let's see both your schematic and a photo of your realisation of the schematic.

Have you put an oscilloscope on the output to see where the distortion is coming from?

My schematic looks like this: