Beginner pin mapping

Hi im new to arduino and i was a bit confused with how the pins are used on the arduino IDE. For example below is the mapping of the arduino nano every:


-if i perhaps wanted to read A3 would i write:

val = analogRead(A3)

or

val = analogRead(22)

-also if i just want to read an analog pin must i always define it using pindmode() in the setup loop?

Did you try it ?

This out: analogRead() - Arduino Reference it gives you code etc. I have read it is not needed but I do it anyway, it never hurts and why waste the time trying to find out. that post was not correct. Over time things do change.

I just wanted to know if the pin name/number are interchangeable and if thats the case which one is better practice?

@arnewbie, your topic has been moved to a more suitable location on the forum.

===

I'm not familiar with the Nano Every but you can try the below simple code to see if A3 matches 22.

void setup()
{
  // set up serial comms; adjust baudrate to your needs
  Serial.begin(57600);
  Serial.println(A3);
}

void loop()
{
}

A3 is just the 'name' for a number.

Please ignore the numbers in the parentheses. Those only indicate the physical pin order as you go around the edge of the board in a counterclockwise direction. They are never used in code and we never ever refer to the pins by these numbers when talking about them here on the forum or in the documentation. They only serve to make the diagram unnecessarily confusing.

The other thing that is potentially confusing is that when you see a pin name with a D prefix (for example, D2), you should refer to it with just the number alone in your code, for example:

pinState = digitalRead(2);

The "D" is only an indicator that this is a digital pin.

1 Like