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.)
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.
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: