Introduction: Automatic Distance Based Volume Control

Picture of Automatic Distance Based Volume Control

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 - https://www.aliexpress.com/item/2PCS-LOT-X9C503P-X...

Datasheet - https://www.intersil.com/content/dam/Intersil/docu...
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 - https://www.aliexpress.com/item/HC-SR04-Ultrasonic...

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.

Picture of 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.

Picture of 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: https://sites.google.com/site/tfagerscode/home/dig...

Step 6: Connect the Speaker.

Picture of 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 :)

Comments

FutureEngineer009 (author)2017-09-27

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

Sure.
I should have provided the link before. Sorry.
Here it is: https://sites.google.com/site/tfagerscode/home/digipotx9cxxx

kksjunior (author)2017-09-02

Nice work...!! Well done

Tesalex (author)kksjunior2017-09-02

Thank you.

About This Instructable

871views

19favorites

License:

Bio: Make your life more lazy and awesome by the touch of electronics. Check out awesome project videos and learn how to build them easily and ... More »
More by Tesalex:RGB Matrix + Spectrum AnalyzerUltrasonic Sensor Based Water Level IndicatorAdd Bluetooth to Your Helmet (Call and Music)
Add instructable to: