Why is A0 declared but Not D12?

hi all,

just i'm testing Arduino Nano for his input and output features.

I wonder why get Compilation Error on referring to i.e. D12, D11,D10..
but A0,A1,A2... is accepted.

Mesage : 'D10 is not declared in this scope'

I have read in this forum that Arduino.h is automatically included,
must not be included expressionally ! I tried this anyway but didnt help.

I dont guess that this has any relevance to the hardware i.e type of Ardiono Nano..

Some suggestions ?

Because A0, … are all macros defined in the system and D12 etc. are not, they are just simple variables.

A0 on a UNO translates into 14, which is the pin number of the analogue input if you want to use it as a digital pin.
It is very often misused to address a pin in an analogRead call, but the system code is smart enough to detect and correct this.

thanks Grumpy-Mike,

its really confusing for a beginner in this stuff, indeed.
Dont know, what the inventors had in mind
with not uniqually name and adress pinadresses independent of capabilities..

so i'm testing anyways..

They want to make it simple and yet cover an ever growing number of different processors on different boards.
The use of the Ax to refer to the digital use of analogue pins was not in the original Arduino software but introduced about ten years ago, because different processors have different physical pins for the analogue capable pins.

So in order for the same sketch to work on a wide number of processors you need to abstract the pin addressing system. The concept of a pin itself is an abstraction of what really happens on a processor, in that all output is done 8 bits, or one byte at a time. On other processor types this is done 16 or 32 bits at a time. So the system software has to make it look like you can change one pin at a time even though when it comedown to it you can’t actually do this.

The popularity of the Arduino system is that this complication and portability is maintained and hidden from the user.

use 12 instead of D12, 11 instead of D11 and so on. I think you get the point.

See the built in examples. there is no example with Dxx ... its always xx when "digital" pins are used.

See the file pins_arduino.h in the right folder (e.g. hardware\arduino\avr\variants\standard) to see what was predefined or what should be available as constants can differ from board to board.