Interrupts in arduino Nano every

Hello.
I have a question about external interrupts in arduino Nano every.

The source code below is
Interrupt pin ... count5 is executed by a change in digital pin 2 (INT0).

It works fine on the arduino nano, but not on the arduino nano every.
The arduino Nano every says that external interrupts are available on all digital pins, but I am having trouble understanding the cause of this problem.

Do I need to write register port control in addition to attachInterrupt?

Thank you all in advance.

int pin5 = 2;

void setup()
{pinMode(pin5, INPUT);
attachInterrupt(digitalPinToInterrupt(0), count5, CHANGE);}

void loop()
{pulse5 = 0;
interrupts(); }

void count5()
{ count5++; }

You are not using the digitalPinToInterrupt() syntax correctly. It is designed to take a pin number as the argument so that you don't need to know the underlying interrupt number for that particular Arduino.
For example, on the Nano Every the interrupt triggered on pin2 is not INT0

count5 is executed by a change in digital pin 2 (INT0).

Use the syntax as designed

attachInterrupt(digitalPinToInterrupt(2), count5,

Thank you for your quick reply.
I was able to run it successfully with arduino Nano every.

Also, some of your questions were incorrect.
In the case of arduino Nano
attachInterrupt((interruptPin), function, mode);
I had made it work with

When I changed to arduino Nano every, it did not work, so I rewrote it, but the syntax was wrong in that case.

I fixed the syntax and found that for arduino Nano every
attachInterrupt((interruptPin), function, mode);
does not work, and
attachInterrupt(digitalPinToInterrupt(digitalPin), function, mode);
works fine.

I learned a lot.
Thank you very much.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.