pin mapping of the ATmega32-16PU

Hi,
I would like to get your help on the pin mapping of the ATmega32-16PU.
I use the library from here https://github.com/HolgerGross/ATmega32-Arduino together with the an USBTinyISB to program this processor with the attached sketch.
My hardware setup is pretty easy (see attached picture).
There is a LED attached to pin 19 of the ATmega32-16PU and a potentiometer attached to +5 V and ground with the slider going to pin 39. I can now adjust the blink rate.
However, that does not match with the pin mapping which I find the pins_arduino.h which reads like this:

/*
                        ATMEL ATmega32
					   
                          +---\\---+
 	   (XCK/T0) D0 PB0	01|        |40  PA0 AI7 D31 (ADC0)
 	       (T1) D1 PB1	02|        |39  PA1 AI6 D30 (ADC1)
 	(INT2/AIN0) D2 PB2	03|        |38  PA2 AI5 D29 (ADC2)
 	 (OC0/AIN1) D3 PB3	04|        |37  PA3 AI4 D28 (ADC3)
	       (SS) D4 PB4	05|        |36  PA4 AI3 D27 (ADC4)
	     (MOSI) D5 PB5	06|        |35  PA5 AI2 D26 (ADC5)
	     (MISO) D6 PB6	07|        |34  PA6 AI1 D25 (ADC6)
	      (SCK) D7 PB7	08|        |33  PA7 AI0 D24 (ADC7)
                 RESET	09|        |32  AREF
                   VCC	10|        |31  GND
                   GND	11|        |30  AVCC
                 XTAL2	12|        |29  PC7 D23 (TOSC2)
                 XTAL1	13|        |28  PC6 D22 (TOSC1)
          (RXD) D8 PD0	14|        |27  PC5 D21 (TDI)
          (TXD) D9 PD1	15|        |26  PC4 D20 (TDO)
        (INT0) D10 PD2	16|        |25  PC3 D19 (TMS)
        (INT1) D11 PD3	17|        |24  PC2 D18 (TCK)
        (OC1B) D12 PD4	18|        |23  PC1 D17 (SDA)
        (OC1A) D13 PD5	19|        |22  PC0 D16 (SCL)
        (ICP1) D14 PD6	20|        |21  PD7 D15 (OC2)
                          +--------+
*/

Why is the pin number in the sketch (const int potPin = 31;) not pin 40 at the ATmega32-16PU ?
Thanks for your help in advance.
Regards, AgeBee

blink.ino (788 Bytes)

There are 32 IO pins, not 40.
Physical device pins are not the same as the software name for the ports. The physical pins are different between DIP and SMD packages, the software only cares about the ports.
The user must take care to attach to the ports intended to be used.

Thanks CrossRoads for your quick reply.
My fault was that I looked up D31 in the picture and thought that this is the pin I have to hook up the input of the poti.

I should have looked up the line where it reads

PA,  // PA1 ** A6 D30

in pins_arduino.h (line 129) seeing that this the one before the last which is physical pin 39 (PA1).