Pin Numbers on AVR MEGA2560


I want to use Interrupts 6 and 7 in the MEGA2560. This is the encircled pins in the image. What pin numbers should I write when declaring these pins as input with pinMode()? I looked at the AVR datasheet but I couldnt find any mention of this anywhere. thank you!

Those pins (PE6 & PE7) do not seem to be broken out to any of the headers on any of the pinouts that I have seen. Can you use pin change interrupts instead?

no, ive already used the pin change interrupts for something else.
i tried pinMode(PE6,INPUT) and pinMode(PE7,INPUT). it didnt give an error so i thought that's it, but when I do a digitalRead on those pins it doesnt seem to be the correct reading, just random 0s or 1s

Those two pins are not wired to anything so, even if you connected wires to them, there are no Arduino pin numbers for them. You could use them with Direct Register Access. You would have to wire to the physical pins. Then you could use "PINE & (1 << PE6)" to read it or "PORTE |= 1 << PE6;" to set it HIGH. DDRE for pinMode(). Manipulate the interrupt registers to enable the external interrupts.

Arduino “PIN numbers” are arbitrary and depend on the “board” you have selected and what “core” you are using. If you have a custom board and are using “megacore” with an appropriate board type (NOT “arduino mega2560”), you can probably refer to the pin as “PIN_PE6”…

i saw this post Arduino Mega Atmega2560 unused pins - #4 by CrossRoads

and i thought it might be an easier solution than direct register access as @johnwasser said (because i havent done that before and im not familiar) i tried it but it still doesnt work.

i do have a custom board but im not using megacore. PE6 and PE7 havent been used before for this board so it wasn't an issue until now. I'm a bit hesitant in using megacore as it might affect other parts of the circuit/code which might cause more problems for me. (im not really sure but i might try this later on)

this is my test code btw.

int pe6;
int pe7;
int pe4; //for digital pin 2

void setup(){
	Serial.begin(9600);
	delay(100);

    pinMode(2,INPUT);
	pinMode(71,INPUT);  //also tried using  PE6 and PIN_PE6
	pinMode(72,INPUT); //also tried using PE7 and PIN_PE7
  
 Serial.println("hello world!");
}


void loop(){
    pe4 = digitalRead(2);
	pe6 = digitalRead(71);
	pe7 = digitalRead(72);
  
  Serial.print("pe4= ");Serial.println(pe4);  //this one works ok!
  Serial.print("pe6= ");Serial.println(pe6);
  Serial.print("pe7= ");Serial.println(pe7);

	delay(5000);
}

Did you updated your IDE with files from the link? Without this you can't use additional pin numbers in the code

You can't use the pin numbers beyond 69 until you put that pins_arduino.h file into Arduino15/packages/arduino/hardware/avr/1.8.6/varients/mega

i couldnt find that directory, but i replaced the one in C:\Program Files (x86)\Arduino\hardware\arduino\avr\variants\mega with the pins_arduino.h from the link. It still didnt work, even after i restarted my pc. is there anything i missed?

i realised that pins PE6 and PE7 are 81 and 82 in this h file, but it still wouldn't give me the correct digitalRead