Hey can anyone help as I'm struggling, I've got 2 pots and 2 buttons hooked up to a nano clone but when adjusted the two pots effect eachothers values. they are wired as per the attached diagram and reporting to the serial monitor.
with both faders down i get 1023 on both and with both faders up i get 48-50 on both as expected.
If I move one fader up and leave the other down the up fader goes to 48-50 as expected but the untouched fader drops to 965.
Ultimately I want the three faders to return their own value between 0-255.
Can anyone help, is this a voltage drop issue and what can I do?
int Fader1 = A0; // select the input pin for Fader 1
int Fader2 = A1; // select the input pin for Fader 2
int Fader3 = A2; // select the input pin for Fader 3
const int But1 = 3; // the number of the button 1 pin
const int But2 = 4; // the number of the button 2 pin
const int But3 = 5; // the number of the button 3 pin
int Fader1val = 0; // variable to store the value coming from the fader
int Fader2val = 0; // variable to store the value coming from the fader
int Fader3val = 0; // variable to store the value coming from the fader
int But1val = 0;
int But2val = 0;
int But3val = 0;
void setup() {
Serial.begin(9600); // Initiate Serial communication.
pinMode(Fader1, INPUT);
pinMode(Fader2, INPUT);
pinMode(Fader3, INPUT);
pinMode(But1, INPUT);
pinMode(But2, INPUT);
pinMode(But3, INPUT);
}
void loop() {
Fader1val = analogRead(Fader1); // read the value from the fader
Fader1val = analogRead(Fader1); // read the value from the fader
Fader2val = analogRead(Fader2); // read the value from the fader
Fader2val = analogRead(Fader2); // read the value from the fader
Fader3val = analogRead(Fader3); // read the value from the fader
Fader3val = analogRead(Fader3); // read the value from the fader
But1val = digitalRead(But1);
But2val = digitalRead(But2);
But3val = digitalRead(But3);
Serial.print("Fader 1 - ");
Serial.print(Fader1val);
Serial.print(" Fader 2 - ");
Serial.print(Fader2val);
Serial.print(" Fader 3 - ");
Serial.print(Fader3val);
Serial.print(" Button 1 - ");
Serial.print(But1val);
Serial.print(" Button 2 - ");
Serial.print(But2val);
Serial.print(" Button 3 - ");
Serial.print(But3val);
Serial.println();
}
I can see no reason why this is happening. You need to use a multimeter and check the voltages under the conditions you have described. you can get a perfectly good one for £4
Crosstalk AFAIK is a problem at higher frequencies, due to coupling between badly routed connecting wires and high impedance circuits.
I also considered bad grounding but that would show the opposite effect to what is described by the OP.
If they are wired correctly the pot values should not normally matter - although it would be informative to know what they are.
(OK very low value - eg 10 ohm pots would affect the supply - but not in a variable way - and very high value, say 10M, would not be correctly read by the ADC)
Otherwise (Refer to diagram)
V1 = Vcc R2/R1+R2
V2 = Vcc R4/R3+R4
and how then is there any interaction between V1 and V2?
Also since the voltages are measured with respect to Vcc, even if Vcc changes the readings should still be unaffected.
The cct is not quite as simple as my diagram shows - the switches are connected to digital inputs in a strange and unnecessarily complicated way and I'm wondering if that has an effect? I'd suggest disconnecting them while testing, or chnging to use input-pullup and just a pb between the digital input and ground.
I'm following this thread with great interest to see what the answer turns out to be.
johnerrington:
Crosstalk AFAIK is a problem at higher frequencies...
Not that kind of cross-talk.
In simple terms,
The sample capacitor of the A/D needs time to charge or discharge to the voltage level of the wiper of the next pot that the A/D multiplexer switches to. That charging or discharging takes more time if the resistance of the pot is higher.
The Atmega datasheet recommends a source impedance of <= 10k.
10kB (10k linear) pots are a good compromise between current draw and source impedance for the A/D.
Leo..
Another trick is to analogRead the pot twice, and use the second result.
But OP could just have connected the pots wrong, and burned the tracks.
Always a good idea with sliders to put them in the middle, and measure the resistance between pins.
The wiper is the one showing half the pot value.
Leo..