RP2040 potentiometer platformio doesnt give right values

Hello.
I have a very simple circuit. Just a 10k ohm potentiometer, connected to GND, +3.3V and the middle pin of the potentiometer is connected to the 27 pin.

Now i programmed it to just print the analog value in serialprint on platformio.

however strangely. if i turn the potentiometer completely to the left, it gives me a analog value of 1023. and completely to the right, i get 1023 as well.
When i put it towards the middle. i will get values moving towards 0.
Typically I should get a 0 when turned to the left, and linearily increasing a 1023 when turning to the right.

Why is this happening? I didn’t have this problem with an arduino.

The code is very simple, I’ll show it here:
Thank you very much!

#include <Arduino.h>

// Define the pin where the potentiometer is connected
const int potentiometerPin = 27;  // GPIO26 (A0) for RP2040

void setup() {
  // Initialize serial communication for debugging
  Serial.begin(115200);

  // Configure the potentiometer pin as an input
  pinMode(potentiometerPin, INPUT);
}

void loop() {
  // Read the analog value from the potentiometer
  int potValue = analogRead(A1);

  // Print the analog value (range: 0-1023)
  Serial.print("Potentiometer Value: ");
  Serial.println(potValue);

  // Add a small delay for better readability of serial output
  delay(500);
}

[EDIT: it doesnt matter if i use A1 or pin 27]

With what platformio.ini is that?

my full platformio.ini is this:

[env:pico]
platform = raspberrypi
board = pico
framework = arduino
monitor_speed = 115200

Okay. So that’s working with ArduinoCore-mbed. In the Arduino IDE, did you install that core or Arduino Pico? There are two different cores.

How do i know or find out what core I have installed?
Why do you mean in the Arduino IDE when using Platform io in VSC.
can i install some core in the libraries section of platformio?

Well do you get the Raspberry Pi Pico board from the “Arduino Mbed OS RP2040 Boards” path or from the “Raspberry Pi Pico / RP2040” path?

I have only Arduino AVR Boards. and nothing else.

Oh. I read this as “I didn’t have this problem with the Arduino IDE”. Never mind.

Let me look into how to use analogRead() with the ArduinoCore-mbed properly… the pin mapping might be wrong, or the voltage is not reaching your pin properly…

Try removing this line.

Try measuring what voltage is reaching GP27 (which is A1) with a multimeter. This should be working normally.

Yeah i’m very confused.
I’ve commented the line u mentioned. Nothing changed.
This is what analogRead i get for different volt measurements of the potentiometer.
3.3V - analogRead: 1023
3.1V - analogRead: 960
3.0V - analogRead: 255
2.9V - analogRead: 511
2.5V - analogRead: 807
2.0V - analogRead: 1023
1.0V - analogRead: 1023
0.1V - analogRead: 1023

Is that the same for all analog pins? GP26 (A0) down to GP29 (A3)?

well some kind of similiar behavior happens with all pins.
But i just realized that when i read lets say:
int potValue = analogRead(A1);
I still get different analogRead values when i connect the pin to either GP26 or GP29.
It seems it doesnt matter what i put into the analogRead().

I also now tried another rp 2040. but i mean its the same model. its some cheap one for 2 euro from china. i wouldn’t think there is much difference.
i believe its still a software problem