Go Down

Topic: How can I control audio volume with Arduino? (Read 4701 times) previous topic - next topic

Jomn

Hi, I'm wondering if there's an easy way to control audio volume with Arduino? I've tried searching but I can only find people who are struggeling with the same... I see people are using digital potentiometers made for this purpose (I guess), but can someone tell me which one to use, a schematic and a arduino scetch? Would be great!

I suppose I should use the signal coming from my phone/laptop before it goes in to the amplifyer.

Thanks!
Be patient, I'm new here :)

Magician

http://www.nlvocables.com/blog/?p=803
Though, I didn't try, just a link in my bookmarks

DVDdoug

Do you know how a regular/manual potentiometer is wired-up?

Digi-Key lists thousands of different digital pots (I'm sure they are not all in stock).   

10k  to 100k Ohms is a good value for line-level audio.  You'll need two for stereo (or you can get a dual digital pot), but you can connect as many as you want to the same control-signals from the Arduino.  You'll probably want to get a thru-hole package if you want to avoid soldering the smaller surface-mount parts.

Different digital pots are controlled differently, and it's your choice of how you want to do it.   The most common method is serial I2C.  There is an  I2C library for the Arduino, so it shoudn't be too difficult.   Some are controlled with a parallel (binary data) connection.    Some have up/down digital controls, which might have an advantage in that you won't get a sudden full-volume blast if there's a little "glitch" i the control data.

An audio volume control has an "audio taper" (approximately logarithmic).  This is because 50% on a regular (linear) pot sounds a lot closer to full-volume than half-volume (due to our logarithmic hearing).   With a digital pot, this can be handled in your sketch.

Jomn

#3
May 03, 2013, 10:50 am Last Edit: May 03, 2013, 05:10 pm by Jomn Reason: 1

Do you know how a regular/manual potentiometer is wired-up?

Digi-Key lists thousands of different digital pots (I'm sure they are not all in stock).  

10k  to 100k Ohms is a good value for line-level audio.  You'll need two for stereo (or you can get a dual digital pot), but you can connect as many as you want to the same control-signals from the Arduino.  You'll probably want to get a thru-hole package if you want to avoid soldering the smaller surface-mount parts.

Different digital pots are controlled differently, and it's your choice of how you want to do it.   The most common method is serial I2C.  There is an  I2C library for the Arduino, so it shoudn't be too difficult.   Some are controlled with a parallel (binary data) connection.    Some have up/down digital controls, which might have an advantage in that you won't get a sudden full-volume blast if there's a little "glitch" i the control data.

An audio volume control has an "audio taper" (approximately logarithmic).  This is because 50% on a regular (linear) pot sounds a lot closer to full-volume than half-volume (due to our logarithmic hearing).   With a digital pot, this can be handled in your sketch.


Thanks a lot!

How about this? http://www.digikey.com/product-detail/en/DS1845E-100%2B/DS1845E-100%2B-ND/956971
Datasheet: http://datasheets.maximintegrated.com/en/ds/DS1845.pdf

How would I wire this up? I've never used Arduino with I2C before... I see theres A0, A1, A2 which is address input. And where do I connect the audio line?

And could you give me a simple sketch to show me how to control it?

Thanks again, very good answer.
Be patient, I'm new here :)

daGuru

If  u r a hobbyist then I suggest that u buy electrical junk like old defective Radios, Stereos, TVs, VCRs ...etc.

Then salvage whatever you need whenever u need it!  ;)

Goodluck


Jomn


If  u r a hobbyist then I suggest that u buy electrical junk like old defective Radios, Stereos, TVs, VCRs ...etc.

Then salvage whatever you need whenever u need it!  ;)

Goodluck

Maybe I'll give it a try. Or I could just hack into the rotaty pot meter on my cheap car stereo I'm using for this project :)

Thanks!
Be patient, I'm new here :)

stcrooks

Hey Jomn. I was in the same boat as you. I opted for a PT2257 to control the volume for a project I have on the go at the moment.

Great way of learning, read the datasheets.
Build the example circuits that most datasheets have, on a breadboard.

It was a bit unfortunate that I couldn't find a lib for the PT2257. So I wrote one myself, which was another challenge for a newbie. (To be honest it's not complete, but it functions for my needs.)

There are some good tutorials here....http://tronixstuff.wordpress.com/2010/10/20/tutorial-arduino-and-the-i2c-bus/

Good luck with your project. It will be frustrating at times, but when you have a working example, you get a great feeling. Then you move onto the next part & start the process again.

Jomn


Hey Jomn. I was in the same boat as you. I opted for a PT2257 to control the volume for a project I have on the go at the moment.

Great way of learning, read the datasheets.
Build the example circuits that most datasheets have, on a breadboard.

It was a bit unfortunate that I couldn't find a lib for the PT2257. So I wrote one myself, which was another challenge for a newbie. (To be honest it's not complete, but it functions for my needs.)

There are some good tutorials here....http://tronixstuff.wordpress.com/2010/10/20/tutorial-arduino-and-the-i2c-bus/

Good luck with your project. It will be frustrating at times, but when you have a working example, you get a great feeling. Then you move onto the next part & start the process again.

Thanks! And yes, I know how it is to feel frustrated and just want to throw it all away, but that just makes it feel even better when it suddenly starts working :D And thank you for the tutorials, I will take a look at them.
Be patient, I'm new here :)

Go Up