How to set pinmode for an analog pin dynamically

Hi,

As I am building a test code for atmega328p using arduino ide.
We can set digital pin using simple int variable;

int pin = 0;

someMethod(){
pinmode(pin,INPUT);
}

how shall i achieve this with analog pin.

Please update asap.
I need this poc done.

Thanks

analogRead does it automatically.

Basically I am sending pin details from server so I am confused what values shall i send. So the pin number is given as a string which i am converting to int and passing to pinmode .

I can use a switch statment and use it select pin using any other character or number but i dont want to skip ahead without understanding it.

Sorry I am newby here.

So if i can know what is the number for a0 , a1,a2,a3 .

a4 a5 i am using for i2c so dont need for that.

Or if u can point me to a link or something would be a great help

@OP

When you say 'analog pin', you must say which one of the following two meanings you hold.

1. There are 6 analog pins (A0 - A5) on the UNO Board. By default, these pins are digital pins like other digital pins -- 2 to 13. As digital pins, the A0 - A5 have these undocumented DPin numbers: 14 to 19 and they can be used in the sketch. Now you can easily execute the following codes to set the direction of A0-pin as digital input line:

int pin = A0;

someMethod()
{
   pinmode(pin,INPUT);
}

2. A0 - A5 pins/lines can be used to sample analog signals from external sources and route them to the internal ADC (analog-to-digital converter) of the MCU. This alternate service of the AX (A0 - A5) pin can be achieved by executing this instruction: analogRead(A0); as has been enunciated by @AWOL in Post#1. Now, A0-pin is no more a digital IO pin; its direction has been automatically changed to input mode.

So the pin number is given as a string which i am converting to int and passing to pinmode .

If you need to know the pin numbers for any of the A* pins just print it in a small sketch
Here is an example for a Nano, which I have to hand

void setup()
{
  Serial.begin(115200);
  Serial.print("A0 : ");
  Serial.println(A0);
  Serial.print("A7 : ");
  Serial.println(A7);
}

void loop()
{
}

and the output is

A0 : 14
A7 : 21