analogRead multiple value Problem

Hi guys,
can someone help me:

I am currently reading 2 values ​​from the potentiometer (i.e. 2 * analogRead). The problem when I adjust the potentiometer the second value is also changed.
Switch to Poti 1: value 0 to 1023 and show me this on the serial monitor.
to potentiometer 2: change values ​​from 0 to 1023 and the value of potentiometer 1 will also influence itself although they are connected separately.
Here below is the program code:

void HandlePot(void){

static int old_val_1=0;
int already_val_1;

static int old_val_2=0;
int already_val_2;

int current_1=analogRead(A2);
int current_2=analogRead(A9);

int current_x1= current_1 * 5 /1023;
int current_x2=current_2 * 5/1023;

already_val_1= current_x1;
already_val_2=  current_x2;

if(already_val_2 != old_val_2){

Serial.println((String) current_x2);




Post the schematic of your project.

Which Arduino board do you use ?

Why do you arrange douple post?

I am using Arduino Mega 2560 board.
I need two values ​​that look right on interface.

I have a simple code down here but always the same problem.

Change potentiometer 1 then the two values ​​will change.

void setup() {
// put your setup code here, to run once:
pinMode(A2, INPUT);

void loop() {
// put your main code here, to run repeatedly:

int current1= analogRead(A2);
int current2=analogRead(A9);

int voltage1= current1 * (5./1023.);
int voltage2= current2 * (5./1023.) ;

Serial.print("Poti_1 ");
Serial.print("Poti_2 ");
delay (1000);

Read each channel twice and only process the second reading.

It works in a virtual world:
I had to change A9 to A7, because the simulation is still in development and only the first analog inputs seems to be implemented.

We like to know more.
You can draw a schematic on a piece of paper and make a photo of it. Or you can tell that it is the same as the simulation.
Can you show a photo ? Perhaps you use a breadboard. They have often bad contacts.

it is the same as the simulation.
i use this adapter for my arduino Mega. (
I think the problem is coming from this adapter.

Tip: That link can be shortened to this:

On the photo it seems good quality, but the Mega board is upside down.
You could check the connections with a multimeter.

Thanks to Whandall for noticing the Doppelpost / double post. Let's hope no one will answer there, or we get confused.

I have deleted your other topic on the same subject. Posting twice on the same subject is against the forum rules because of the possibility of 2 different groups of volunteers spending their time trying to help, each unaware of what the other is doing. I kept this topic as it has the most replies.

Please read How to get the best out of this forum


Shows us the wiring plz