AIN11 is PB3, and in variant.cpp of sodaq_one this is pin 13.
It’s not working when I define pin 13 for the button.
When I define pin 19 (instead of 13): it works. Why?
When I defined BUTTON_PIN 19, I was using
attachInterrupt(digitalPinToInterrupt(BUTTON_PIN), ButtonChange, CHANGE);
digitalPinToInterrupt(19) is 0, so this is the same as
attachInterrupt(0, ButtonChange, CHANGE);
But this “pin” 0 is converted to interrupt 2.
PA2 is using interrupt 2.
That is why connecting the external button to PA2 (AIN0) worked.
So, lesson learned: check WInterrupts.c and use the pin number in attachInterrupt.
attachInterrupt(BUTTON_PIN, ButtonChange, CHANGE);