Automatic Distance Based Volume Control




Introduction: Automatic Distance Based Volume Control

About: Make your life more lazy and awesome by the touch of electronics. Check out awesome projects and learn how to build them easily and cheaply.

In this Instructable, I'll demonstrate the working of a digital potentiometer and make a distance based volume control project with which you can change the volume of a speaker according to the distance sensed by a distance sensor.

A digital potentiometer or digi pot does the same function as a normal or mechanical potentiometer but instead of mechanical action it uses digital signals. There are various types of digi pots available out there like MCP4131, AD5252 etc. I will be demonstrating X9C503P IC which is a 50kohm digi pot.

By the end of this project, you'll be able to make some really cool projects using this IC, for example an Automatic Distance Based Volume Control System which I will also demonstrate.

Step 1: Watch the Video.

The video contains all the steps in detail to understand how the digipot works, and also how to build the project.

So, go ahead and watch it.

Step 2: Parts Required.

1. Digi Pot -

Datasheet -
The datasheet is a good source to get more acquainted with this IC. It will surely help you if take a glance at it.

2. Ultrasonic Sensor -

3. Push Buttons - 2

4. 1K Resistor - 2

5. Arduino - any kind

6. Speakers

If you are using a small speaker (like 0.5 Watt) then it's alright, but if you are using something like greater than 3 Watts, you will need an amp.

7. LED with current limiting resistor (low value like 470 ohms).

Step 3: Test the Digi Pot IC.

On a breadboard, make this circuit. It demonstrates the working of digipot without a microcotroller. From this circuit and the datasheet, you should understand pretty much everything of how this IC works,

Even, you can write your own code if you want to use it with a microcontroller.

You can see it in action in the video also.

Step 4: Test the Ultrasonic Sensor.

Connect the trigger pin of sensor to pin 13 or Arduino, echo to pin 12 and apply power. Upload the sketch included in this step. Open serial monitor. With an obstacle, vary the distance between sensor and obstacle by going back and forth, and the serial monitor will give you exact value of the distance between sensor and the obstacle at every instant.

After you are sure, sensor is working fine, move on to the next step.

Step 5: Ultrasonic Sensor and Digi Pot Working As One.

Again make connections according the circuit diagram in this step and upload the sketch attached to this step as well.

Again vary the distance, the LED brightness should change with the changing distance.

Refer to video to see it in action.

Keep in mind, to change the maximum value in map function (refer picture) to maximum possible distance in your project. This will make it look more cool.

DigiPot Library:

Step 6: Connect the Speaker.

Now replace the LED with a speaker. Connect any one wire of the speaker through the digi pot like you connect a switch.

Note that, if you are using an amplifier, connect the digi pot at the input of the amplifier.

Previously, LED brightness was changing, and now volume of the speaker will change.

Step 7: Done!

This wraps up our Instructable. Let me know if you come up with any idea for this IC.

Thank you for reading :)

Be the First to Share


    • The 1000th Contest

      The 1000th Contest
    • Battery Powered Contest

      Battery Powered Contest
    • Hand Tools Only Challenge

      Hand Tools Only Challenge

    5 Discussions


    1 year ago

    Hi, could you pls tell me the way you use your phone as a memory module for speaker to play sound?


    3 years ago

    Hi! Can u pls tell me where can i get the digipot library? This would be so helpful in our project.


    Reply 3 years ago

    I should have provided the link before. Sorry.
    Here it is:


    3 years ago

    Nice work...!! Well done


    Reply 3 years ago

    Thank you.