Pages: [1]   Go Down
Author Topic: How can I control audio volume with Arduino?  (Read 3218 times)
0 Members and 1 Guest are viewing this topic.
Norway
Offline Offline
Newbie
*
Karma: 0
Posts: 19
Be patient, I'm new here :)
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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!
Logged

Be patient, I'm new here smiley

Montreal
Offline Offline
Faraday Member
**
Karma: 27
Posts: 2566
Per aspera ad astra.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Offline Offline
Edison Member
*
Karma: 32
Posts: 1282
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Norway
Offline Offline
Newbie
*
Karma: 0
Posts: 19
Be patient, I'm new here :)
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
« Last Edit: May 03, 2013, 10:10:50 am by Jomn » Logged

Be patient, I'm new here smiley

Offline Offline
Newbie
*
Karma: 0
Posts: 2
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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!  smiley-wink

Goodluck

Logged

Norway
Offline Offline
Newbie
*
Karma: 0
Posts: 19
Be patient, I'm new here :)
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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!  smiley-wink

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 smiley

Thanks!
Logged

Be patient, I'm new here smiley

Offline Offline
Newbie
*
Karma: 1
Posts: 7
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Norway
Offline Offline
Newbie
*
Karma: 0
Posts: 19
Be patient, I'm new here :)
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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 smiley-grin And thank you for the tutorials, I will take a look at them.
Logged

Be patient, I'm new here smiley

Pages: [1]   Go Up
Jump to: