Arduino Mega interrupts

The Arduino reference for attachInterrupt command gives this chart for interrupts and pins on the Mega board:

BOARD INT.0 INT.1 INT.2 INT.3 INT.4 INT.5

Mega2560 2 3 21 20 19 18

However may pinout diagrams show:

INT.0 on Pin 21
INT.1 on pin 20
INT.2 on pin 19
INT.3 on Pin 18
INT.4 on Pin 2
INT.5 on Pin 3

Which is correct?

You have shown two different sets of data from undefined sources. I can only assume that you made up the data. You tell us which set you made up correctly, and which set you got wrong.

It would be pretty simple to test which pin triggers which interrupt.

It is correct for Mega board. The reference for attachInterrupt has ordered according pin number. Check this on the schematic if you are not sure. But this is correct:
INT.0 on Pin 21
INT.1 on pin 20
INT.2 on pin 19
INT.3 on Pin 18
INT.4 on Pin 2
INT.5 on Pin 3

The first set of information is from the 'Arduino Reference' page of this site. Look up attachInterrupt syntax. I copied the information from the chart that is on that page. it is not made up. the Bottom part of the information is from a diagram that shows the pinout of the Meag board. if you do a search for the Mega board pinout you will get this. Also a search for a schematic for the Meaga board shows the same information wich again shows that it is different from the Arduino reference page.

Why not use digitalPinToInterrupt() to completely hide this detail?

[BTW you can always look in ..../hardware/arduino/avr/variants/mega/pins_arduino.h in
your downloaded Arduino IDE to see exactly whats defined ]

Budvar10,

Thank you

When in doubt, you can always reference the datasheet.

INT -> chip pin - mega pin
INT0 -> 43 - 21
INT1 -> 44 - 20
INT2 -> 45 - 19
INT3 -> 46 - 18
INT4 -> 6 - 2
INT5 -> 7 - 3

It's worth noting that many of the pinout diagrams for the mega have incorrectly labelled Arduino pin 3 as being chip pin 3 (in conflict with Arduino pin 1) and should be chip pin 7.

I think this explains the confusion:

Pert - Thank you for that info. It does clarify things.