Multiplexer and Potentiometers fluctuation value

Hi guys,

For my project i need a bunch of controls so i figured it would be good to use multiplexers and potentiometers.

The problem is: when i try to read the potentiometers, some of them fluctuate in value without touching the potentiometers.

When reading only one multiplexer channel over and over, without touching the potentiometer, the value changes from 0 to 1023.

I connected 8 poties to the channels of the multiplexer and use the vcc and vee as +5V and GND in parrallel.

Why do my values keep changing? Could the cables be loose ? - but then why is it reaching 1023?
My best guess is that i did something wrong when connecting them.

I would appreciate any help on this :slight_smile:

Look up hysteresis on this site. There are some solutions for stabilising potentiometers e.g. Hysteresis - Introductory Tutorials - Arduino Forum

6v6gt:
Look up hysteresis on this site. There are some solutions for stabilising potentiometers e.g. Hysteresis - Introductory Tutorials - Arduino Forum

Thanks for the answer!
Though, some values remain constant and others just keep changing in the full range, not only a few percent. I cant seem to get anything close to a constant value for some poties... I guess I am looking for hardware solutions

PS: This is a related topic, I am going to try to follow the solutions. hopefully it helps

Can't follow that wiring or see what components are being used. Can you post a schematic please? And your code. Please read the forum guidelines in the sticky post before you do that, so you know how to do it right.

You might try reading the analog pin twice after changing the multiplexer address, and discard the first reading.

If those connectors just push onto the pots it could well be a bad connection , you really need to solder to the pots.

A better wiring plan would be to have a board and bring all the individual 0v and Vcc connections to that “star “ fashion . Much easier to spot a fault . Also connect one at a time and check it works ok.

Oh ..and ... used pots may be worn and the reading will jump about

Why eight pots anyway - you don’t have enough hands to twiddle them all at the same time...so..why not one pot and eight digitals . Select a switch , read and store the pot value to a corresponding variable, next switch , adjust the pot and store the value and so on . The digital
Indicating which channel the pot value corresponds to .

What is the “multiplexer” you mention , how is it wired and how is it read by the Arduino - that could well be the issue too. Seems a shame to multiplex analog values send them to an Arduino which multiplexes the analog inputs. You could at least run some direct and some through my switching method.

Thanks for your answers guys,

I cant upload a schematic..
but I put everything in a breadboard and it now works perfectly!? So it definetly is bad soldering at my part.

Of course I could just use one Poti or connect some directly but my goal is to have 6 Multiplexer with each 8 poties. It is for a soundsynthesizer I am trying to construct so I need this many poties. Once I finished it, I will share my full code and try to do schematics.

This code I am using is simply for reading the potentiometers and printing the output:

int potiWert = 0;
int zaehler = 0;

int bit1 = 0;
int bit2 = 0;
int bit3 = 0;

void setup() {
 pinMode(8, OUTPUT);
 pinMode(9, OUTPUT);
 pinMode(10, OUTPUT);
 pinMode(A0, INPUT);
 Serial.begin(9600);
 
digitalWrite(8,0); 
digitalWrite(9,0); 
digitalWrite(10,0);
}

void loop () {
 for ( zaehler = 0 ; zaehler <= 7; zaehler++ ) {

  bit1 = bitRead(zaehler, 0);
  bit2 = bitRead(zaehler, 1);
  bit3 = bitRead(zaehler, 2);

  digitalWrite(8, bit1);
  digitalWrite(9, bit2);
  digitalWrite(10, bit3);

  potiWert = analogRead(A0);
 
  Serial.print(potiWert);
  Serial.print(" ");
  //delay(10);
  } 
  delay(100);
 Serial.println("");
 }

however, my Arduino hangs up after some iterations running this code.

Why eight pots anyway - you don't have enough hands to twiddle them all at the same time...so..why not one pot and eight digitals . Select a switch

You can't do that because pots have mechanical memory. For example, let's say you want to share one pot for bass & treble on a stereo. If you set the bass at 3 o'clock and the treble at 9 o'clock, the old settings are immediately messed-up when you change the switch.

You can share a rotary encoder but then you loose your mechanical memory (which you might want) and the mechanical position doesn't give any clue to the setting so you need some kind of display. And you can't quickly grab a knob to make an adjustment. ...The best solution depends on the application and what kind of user interface you want.

If you cannot upload a schematic, then I would suggest the following idea: do not give up so easily! We will try to help you upload it. What error message do you see when you try to upload a schematic? What app and file format are you using?

You say your code "hangs". What do you see happening?

others just keep changing in the full range, not only a few percent. I cant seem to get anything close to a constant value for some poties

Which almost certainly means that the analog inputs are floating. That is the voltage on the wiper is not being switched through to the input. What do you get when you measure the voltage on the wiper of the pot that do this, compared with the voltage on the analogue inputs.

If you haven't got a meter, then buy one, they can be had for less than $10.