A5 is defined but D5 is not

If I used D5 in my code I get an undefined message (Nano):

But if as an experiment I put A5 it compiles.

void setup() {
  // put your setup code here, to run once:
  pinMode (D5,INPUT_PULLUP) ;
}

void loop() {
  // put your main code here, to run repeatedly:
  digitalRead (D5)
}

What again have I missed? This is the new IDE if that makes a difference...

Try it without the ā€œDā€
pinMode (5,INPUT_PULLUP) ;

It would be nice if the Silkscreens matched the IDE:

If you look in the system file (note1) pins_arduino.h:

static const uint8_t SDA = PIN_WIRE_SDA;
static const uint8_t SCL = PIN_WIRE_SCL;

#define LED_BUILTIN 13

#define PIN_A0   (14)
#define PIN_A1   (15)
#define PIN_A2   (16)
#define PIN_A3   (17)
#define PIN_A4   (18)
#define PIN_A5   (19)
#define PIN_A6   (20)
#define PIN_A7   (21)

static const uint8_t A0 = PIN_A0;
static const uint8_t A1 = PIN_A1;
static const uint8_t A2 = PIN_A2;
static const uint8_t A3 = PIN_A3;
static const uint8_t A4 = PIN_A4;
static const uint8_t A5 = PIN_A5;
static const uint8_t A6 = PIN_A6;
static const uint8_t A7 = PIN_A7;

You can see it has definitions for A0 to A7, but no such definition for D5 etc.
Note1: I didn't use the Arduino IDE (1.8.?), I used a PlatformIO project that uses the Nano. I don't remember how to find the system header files in the IDE. With PlatformIO I can just right click on e.g. A1 and select "go to definition". I chose to do that now because it's easier for me.

Just so I have understood: 5 is the pin number to use in the source file to get digital i/o pin 5?

And I could in my sources do this:

#define D5 5
#define D6 6
// etc. etc.

That would be clearer (for me).

That is correct.

That would work, but maybe this only seems clearer because you haven't done much work using the standard pin definitions yet.
What I find useful is to have a header file like this, for each project, particularly for projects containing multiple files:
Portpins.h

#ifndef PortPins_h
#define PortPins_h

// used by nano serial  0
// used by nano serial  1
#define PIN_Z80_D1      2
#define PIN_Z80_D0      3
#define PIN_Z80_D2      4
#define PIN_Z80_D3      5
#define PIN_Z80_D4      6
#define PIN_Z80_D5      7
#define PIN_165_SERIN   8
#define PIN_Z80_D6      9
// free                10
// free                11
#define PIN_Z80_RESET  12
#define PIN_165_SHCLK  13
#define PIN_165_SHLD   A0
#define PIN_Z80_D7     A1
#define PIN_Z80_CLK    A2
#define PIN_Z80_INT    A3
#define PIN_Z80_NMI    A4
// free                A5
// free analog only    A6
// free analog only    A7
#endif

I.e. define what you are using the pins for. That makes the sketch code more readable.

That's easy.

For digging up a link to the source for posting, I usually search for "github arduino core" and then find the lines:

The rest of the file shows how it's all defined by an array of digital pin numbers, and how all the other definitions are defined.

You could, but since the underlying indexing for everything else is the "digital pin number as used by digitalRead(pin)" all that would be is prefixing the digital pin number with a "D". You could do something similar with a macro:

#define MYDIGITALPIN(x) (x)
...
const int switchPin = MYDIGITALPIN(5);
...
digitalRead(switchPin);

Seems to me that everyone is showing you that In the Arduino IDE the pins are actually declared as static const uint8_t and not by using a #define.

That seems a good idea, yes.

Dave Lowther's idea seems good to me.

Are you suggesting I use

static const uint8_t ikBuzzerPin = 5 ;

instead of a define? That'd work too.

If you are going to give your pins descriptive names like "buzzer" then const int is the usual way to do it. You don't need the static part.
So:

const int ikBuzzerPin = 5;

Using #define is frowned upon by most experienced C coders.

Guilty. I agree using const int is better, perhaps const byte is even better.

I didn't want to criticize since I mis-use #defines in my own code.

If I understand correctly, #define is called a 'pre compile directive' and acts just like the 'search and replace' in a word processor.

I thought about that static part after I posted, I'd just copied your example without thinking... :frowning:

Just

const int

is good

You will find several debates on the forum about using #define Vs const