"analogRead(A3)" of circuit with potentiometer - values unstable?

I’m a newbee with Arduino. Just started playing. I’m working through an exercise with a potentiometer connected to Uno 5V, GND & A3 in the circuit. (Attempting to insert a picture of the board with connections.)

UPDATE

18-May-2020 - Figured out I had not pressed the potentiometer into the breadboard firm enough. Reseated the potentiometer and all is working as expected.

Running the following script:

void setup() {
  // put your setup code here, to run once:
  Serial.begin(9600);
  Serial.println("ELEGOO UNO R3");
  Serial.println("------------------");
  Serial.println("ELEGOO UNO R3: +5v to Potentiometer pin 1");
  Serial.println("ELEGOO UNO R3: GND to Potentiometer pin 2");
  Serial.println("ELEGOO UNO R3: A3  to Potentiometer pin 3");
  Serial.println("");
  Serial.println("analogRead(A3) values");
  Serial.println("-----------------------------");
}

void loop() {
  // put your main code here, to run repeatedly:
  Serial.print("A3: ");
  Serial.println(analogRead(A3));
  delay(1000);
}

Here’s the output from my serial com port log. My returned values are all over the place (output is timestampted and potentiometer in set in the middle and not being moved.)

13:55:18.457 -> ELEGOO UNO R3
13:55:18.457 -> ------------------
13:55:18.511 -> ELEGOO UNO R3: +5v to Potentiometer pin 1
13:55:18.558 -> ELEGOO UNO R3: GND to Potentiometer pin 2
13:55:18.611 -> ELEGOO UNO R3: A3  to Potentiometer pin 3
13:55:18.611 -> 
13:55:18.611 -> analogRead(A3) values
13:55:18.658 -> -----------------------------
13:55:18.712 -> A3: 488
13:55:19.654 -> A3: 76
13:55:20.658 -> A3: 627
13:55:21.613 -> A3: 1004
13:55:22.617 -> A3: 1023
13:55:23.620 -> A3: 934
13:55:24.624 -> A3: 405
13:55:25.627 -> A3: 59
13:55:26.648 -> A3: 0
13:55:27.652 -> A3: 70
13:55:28.656 -> A3: 568
13:55:29.659 -> A3: 945
13:55:30.663 -> A3: 1023
13:55:31.634 -> A3: 1006
13:55:32.638 -> A3: 522
13:55:33.642 -> A3: 110
13:55:34.646 -> A3: 27
13:55:35.650 -> A3: 22
13:55:36.654 -> A3: 424
13:55:37.658 -> A3: 902
13:55:38.661 -> A3: 1019
13:55:39.665 -> A3: 1023
13:55:40.669 -> A3: 691
13:55:41.686 -> A3: 175
13:55:42.690 -> A3: 60

I was expecting the values returned to be stable and change from 0 to 1023 as I moved the potentiometer.

Can anyone provide some insights as to what may be going on?

Assume you have a wiper-type variable resistor.

Do you have one of the outer legs connected to 0V, the other outside leg of the resistor connected to 5V and the middle leg of the resistor connected to A3? All connections secure?

can you post a photo or drawing of your setup if you don't

You can also model arduino circuits on TinkerCAD and post a link there - the code can also be run from there as a simulator.

Hello Andrew, thanks for the reply. Here's the URL link to a picture. I believe it shows I'm connected as you describe.

Reviewing the log of the analogRead(A3) values it looks like the values are cycling from low to high to low to high ...

I'm going to remove the potentiometer and see what happens... see if the voltage is varying. Without the potentiometer I would think I should have a constant 1023 value returned from the analogRead(A3).

UPDATE:
Ok, taking the potentiometer out of the circuit, just going from Arduino UNO 5v or 3.3v to A3 I get as expected... 1023 consistently from 5v, and 697/698 from 3.3v. So both my potentiometers must be faulty is my guess.

Following is log of me moving wire from 5v to 3.3v and back to 5v:

15:19:19.269 -> ELEGOO UNO R3
15:19:19.301 -> ------------------
15:19:19.301 -> ELEGOO UNO R3: +5v to Potentiometer pin 1
15:19:19.335 -> ELEGOO UNO R3: GND to Potentiometer pin 2
15:19:19.402 -> ELEGOO UNO R3: A3  to Potentiometer pin 3
15:19:19.436 -> 
15:19:19.436 -> analogRead(A3) values
15:19:19.469 -> -----------------------------
15:19:19.503 -> A3: 1023
15:19:20.454 -> A3: 1023
15:19:21.428 -> A3: 1023
15:19:22.442 -> A3: 1023
15:19:23.457 -> A3: 777
15:19:24.438 -> A3: 0
15:19:25.456 -> A3: 0
15:19:26.439 -> A3: 0
15:19:27.465 -> A3: 510
15:19:28.445 -> A3: 1023
15:19:29.454 -> A3: 698
15:19:30.459 -> A3: 697
15:19:31.468 -> A3: 698
15:19:32.456 -> A3: 697
15:19:33.459 -> A3: 697
15:19:34.481 -> A3: 697
15:19:35.456 -> A3: 697
15:19:36.468 -> A3: 1023
15:19:37.488 -> A3: 1023

(Do you know how to include an image in the post?)

Could you also take a few moments to Learn How To Use The Forum.
Other general help and troubleshooting advice can be found here.
It will help you get the best out of the forum in the future.

They will also tell you how to include pictures :slight_smile:

Thanks Shannon, So sorry if I used the forum incorrectly. I'll go review the "Learn How To Use The Forum."

I finally figured out my problem... I had not pressed the potentiometer into the breadboard firmly enough. Reseated and all is working as expected.

Thanks again! Sorry for any misuse of the forum.

Sandy

No need to apologise.
You just skipped past the bits that would help you thats all.