Potnetiometers and analog inputs

Good morning.

I connected a B10K, 0° to 270° potentiometer to an arduino pro mini, one end of the potentiometer to Vcc (5V) and the other to the ground, the middle terminal to pin A0. When I read the data on pin A0 through a serial monitor, it was not linear at all.
From 0° to 210° it was reading less than 10, up to 250° was less than 100 and suddenly, in the last 20° it goes from 100 to almost 1000, id didn't reach 1023.
Could someone please help me to understand what's going on?
Is it expected? I mean, if I use these data to control a power source it will be linear?

Here is the code:

int Ppot = A0;
int Vpot;
int Pbas = 10;

void setup() {
pinMode(Pbas, OUTPUT);
pinMode(Ppot, OUTPUT);
Serial.begin(9600);

}

void loop() {
Vpot = analogRead(Ppot);
//Vpot = map(Vpot,0,900,0,254);
Serial.println(Vpot);
}

Thank you all, stay health

Why have you set your input pin Ppot to OUTPUT mode?

Steve

OMG
The only answer is, I'm 60 years old, did that late at night and didn't review all the sketch
Thank you very much

I suspect your pot is an "audio pot", they are logarithmic not linear.
If you swap the plus side with the minus side of the pot, not the wiper, I suspect you will see the opposite effect that you have now.

potentiometer is linear, what was wrong is the line on code where I declare the analog input as an output, I erased that line and works perfectly

Thank you anyway

Thanks for posting the finding. When I read the symptom I jump to a conclusion without fully reading all the information. Hopefully I learned from this too.

LaserSteve:
Thanks for posting the finding. When I read the symptom I jump to a conclusion without fully reading all the information. Hopefully I learned from this too.

Log pots are generally type A (Audio taper) so B types as in B10K are (almost) always linear.

Steve

Thanks everyone, the most important lesson I learned is to always review the code with clear mind and that there are good people here to help.

Thank you again.