So I was using my Uno today, Windows 10 Pro, Arduino Ide 1.8.13, ran a program that wasn't working as I expected. So I then decided to just try a simple sketch reading a value from a potentiometer . No matter where I placed the pot by turning I would not get full voltage and what changed is not what I expected, I should be able to get 0 to 5VDC or close . I put vcc to pin 1, G pin 3 and A2 to pin2 . See photo Like I said a simple read.
So no matter where I set the pot it doesn't read properly, I checked the settings , I made sure that there were no other sketches open. I removed all wires and loaded a blank sketch , serial window is clear. I did a loop back test and typed Hello World and it responded. I reloaded the sketch and same results. I have another Arduino Uno , plugged that in and still same thing, I thought maybe something was wrong with my Arduino but that proved to be false.
int readVal;
int myPin=A2;
float V2;
int dt=250;
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
}
void loop() {
// put your main code here, to run repeatedly:
readVal=analogRead(myPin);
V2=(5.0/1023.)*readVal;
Serial.print("Pot ");
Serial.println(V2);
delay(dt);
}


