Arduino UNO R4, AnalogRead returns strange values

When I tested the following code on my Arduino Uno R4 Minima,
I cannot get 0 and 1023.
Arduino Uno R4 WiFi also showed the same thing.
When I ran the code on my Arduino Uno R3, I can get 0 and 1023,
that means no problem with my variable registor and wires.

Did I miss something?

int pin_vr = A1;

void setup() {
  pinMode(pin_vr, INPUT);
	Serial.begin(9600);
  while (!Serial) ;
}

void loop() {
	int value = analogRead(pin_vr);

	Serial.println(String(value));

	delay(100);
}

This is the resulting plot.
Minimum value is about 20, and maximum value is about 900.

What values do you get on the R4s if you take pin A1 directly to GND or 5V ?

Thank you for your comment.

When I take pin A1 directly to GND, I got 0
and directly to VCC, I got 1023.

As I said, I did exactly the same thing with Arduino Uno R3.
Same variable resistor, same wires, same breadboard, same sketch
and I got 0 and 1023.

I am trying to figure out what is the difference.
Does anyone have similar experience or can give some hints about this?

Try adding a 0.1uF capacitor from A1 to ground and see if that clears your readings up.

Thank you for your valuable comment.
I added 0.1uF capacitor from A1 to ground and I can get 0 and 1023.
Still there is a little bit fluctuation but much better than before.

When I tested some other Arduino boards with SAMD21 microcontroller
there was no problem like this.

This is the difference between SAMD21 and RA4M1 ?

I will dig out RA4M1 datasheet.
Any clues regarding the analog input characteristics of the RA4M1 would be welcome.

This is the resulting plot when I put 0.1uF capacitor.

Thank you again for you all and especially van_der_decken :slight_smile: