Read volume from potmeter and display on LCD

Hello

I've been working on a project of mine, which is an arcademachine. I've installed an amplifier into the machine and connected it to speakers via a potentiometer.

However, I would like to read the volume that is being played somehow, and display it on the LCD.
Some help on this would be appreciated, I don't know how I would go about connecting it, or writing code about it.

Maybe start with some tutorials?

Can you add an extra gang to the volume pot, and wire the new gang to the Arduino?
(Isolated from the volume circuit, obviously)

Alternatively, an absolute encoder.

show

Do you want to read the signal volume or the pot position?

It's easier to read signal, but not as easy as reading the position of a dedicated pot that you can apply a DC voltage to with audio going through it.

This tutorial has RECORD and PLAYBACK for your potentiometers.

That is a very bad idea. It is normal to add a volume control to the input of an amplifier.
Pots have a very low power rating and you could easily burn them out at the end of track settings, where all the power is dissipated over an increasingly small part of the track.

What sort of amplifier is this?

Post #3 @anon73444976 has the answer, use a two ganged pot. These are normally for stereo volume control, but you use the extra pot to connect to the Arduino. Also note volume controls normally use a log law pot so the perceived volume change matches the angle of rotation. A normal linear pot will have all the adjustment at one end with not very much at the other.

So to get a linear reading for the display you will have to apply an inverse log function to the reading before you send it to the display.

Hi, @jellito
Can you please post a basic circuit diagram showing the amplifier, your pot and the speakers?
Please label your components, and identify pins used as well as component values.

Thanks.. Tom... :smiley: :+1: :coffee: :australia:

Sorry for the late answer, i think i figured out how to wire it up but I made this code that works off of 5V. However, I'd like it to work with 0.05V instead. What do I have to switch up?

#include <LiquidCrystal.h>

LiquidCrystal lcd(12, 11, 5, 4, 3, 2); // Initaliseert de LCD
int sensorPin = A0;
int sensorPin2 = A1;
int x;
int percent;
int x2;
int percent2;



void setup() {
  
  lcd.begin(16,2); // Start een LCD met een 16x2 configuratie
  lcd.clear();
  lcd.setCursor(5, 0);
  lcd.print("VOLUME"); // Print LED op de LCD

 
 

}
 
void loop() {
  
analogRead(sensorPin);
analogRead(sensorPin2);
  
x = analogRead(sensorPin);  
percent = map(x, 0, 1024, 0, 101);  
Serial.println(percent); 
x2 = analogRead(sensorPin2);
percent2 = map (x2, 0,1024, 0, 101);
  
lcd.setCursor(5,1); // Volgende regel op de LCD
lcd.print(" "); // Print enkele spaties
if (percent<100) 
lcd.print('0');
if (percent<10) 
lcd.print('0');
lcd.print(percent); // Print de waarde van de R LED
lcd.print('%');
}



Can you explain what you mean by that? It makes no sense to me.
Why do you want to change it?

Not with an external supply like that you haven't.
I am assuming this is the second gang of a two gang pot.

Just for the record

  1. This is not a schematic it is a physical layout diagram.
  2. It does not show the amplifier.
  3. It does not show the speakers.

Finally your code shows two sensor pins but you diagram does not.

If you haven't got a ganged pot there there is all sorts of things you are not understanding. Things you will have to do before it will work. This will involve some electronic construction which will eventually have to be transferred to strip board and soldered up to make it permanent. Are you willing / capable of doing this?

There are two ways you can do this:-

  1. You need to isolate the signal going to the audio amplifier with a voltage follower, normally made with an operational amplifier. Then you need to amplify the signal so that it gives you a 2.5V peak to peak signal. Then you need to follow that with a peak detector, with some smoothing and only then can you worry about the software.

  2. Another way would be to use a digital pot to control the volume based on a reading from an analogue pot connected to the 5V line. Then use that reading to control both the display and the digital pot. The problem with this is that each time the digital pot changes value there is a small bit of noise injected into the system and it can sound like a zippier being pulled. There are ways round this they involve only sending a change in volume when the signal is at or about 0V with respect to the signal ground. But it can get complex despite the initially sounding simplicity.

If you want to go down this route we can help you with the initial circuit design.

The AUX signal going to the potentiometer is 0.05V, that's why I wanted 0.05V. The external power supply is essentially the voltage of the audio source.

My potmeter is a dual gang logarithmic potentiometer

Hi,

But it won't be 0.05V all the time if a sound signal is running through the volume control.

DO YOU WANT TO SHOW POTENTIOMETER POSITION OR SOUND LEVEL?

If you want pot position then you need a separate track (dual track) potentiometer, one to vary the sound volume and the other to provide a signal proportional to the pot position, not the sound signals varying volume.

Please answer the highlighted question, there is a big difference between each.

Also how did you measure the 0.05V signal, AC or DC?

PLEASE show a simple diagram of how you have the amplifier, pot and speakers connected.
PLEASE post an image of a hand drawn diagram.

Thanks.. Tom... :smiley: :+1: :coffee: :australia:

Why? Why not connect it to 5V? You should not be using an audio signal here.

You can change the reference voltage of the A/D to 1,1V then each voltage step you can measure is 1mV so at 50 mV you only have 50 steps so you can't have each percentage displayed. In practice because of noise you will be lucky to get a resolution of 4%.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.