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.

"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.Do not send technical questions via personal messaging - they will be ignored.

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.

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.

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: