More ATTiny pin confusion

I’ve successfully programmed an ATTiny86 to do what I want it to do, following the various tutorials and starting with the modified “blink” sketch and pin assignments as shown here

and here

both of which examples refer to ATTiny PB0/Pin 5 as Pin 0.

So in my sketch, as a reminder, I’ve included code thus (as per the Blink exercise)

#define PB0 0;
#define PB1 1;
#define PB2 2;

  const int RedLedPin = PB0;            // set pin numbers 
  const int YellowLedPin = PB1; 
  const int BlueLedPin   = PB2;

and then of course I have code like this

  pinMode(RedLedPin, OUTPUT);       //Pinmodes
  pinMode(YellowLedPin, OUTPUT);       //
  pinMode(BlueLedPin, OUTPUT);

followed by code to write to the pins

And it works - the Red led on Pin 5 lights up when it is supposed to, as does the Yellow LED on pin 6 and the blue LED on pin 7.

BUT I don’t understand why when I am assigning them to pins 0, 1, and 2 respectively!

What happens when I want to use PB4/Pin 3 - what do I call it, pin 5 or pin 6?

Or is it that the #define statements are irrelevant and simply ignored by the compiler, so when I use PB4, I should refer to it as PB4 but don’t bother with the #define statement?

I have searched this forum, and other sites, but I haven’t got any clearer I’m afraid!

The arduino functions like pinMode() and digitalWrite() take a "pin number" argument that is an ARBITRARY integer and has nothing to do with the AVR port number or bit number within that port. The Arduino pin number is mapped inside those functions to a Port (ie PORTB) and Bit (0b01000 or something) in a way that is defined for the particular board you have selected (by variant.h and/or variant.cpp in the source code. Or pins_arduino in older cores.) This is a little obscured on the TINY chips, which only have a single port, and more obvious on something like a MEGA because "pin number 50" obvious is not just a bit number. usually there's a nice picture somewhere. In this case, pins_arduino.c has this picture:

//                  +-\/-+
// Ain0 (D 5) PB5  1|    |8  Vcc
// Ain3 (D 3) PB3  2|    |7  PB2 (D 2)  Ain1
// Ain2 (D 4) PB4  3|    |6  PB1 (D 1) pwm1
//            GND  4|    |5  PB0 (D 0) pwm0
//                  +----+

So... You should NOT refer to the pins as PB4, etc. The definitions you added for the PBx values are pointless (and wrong - they have extra semicolons) (and they probably generate compiler warnings or errors because the AVR code already defines those names as bit-numbers. (although in this case, the bit numbers and the pin numbers are the same.)

What happens when I want to use PB4/Pin 3 - what do I call it, pin 5 or pin 6?

You should call it "4"

I should refer to it as PB4

When using the Arduino functions, you should NEVER refer to it as PB4.