// Question: Does pin 19 interrupt work and can PORTD be read ?
// Answer: Yes
int interruptPin = 19;
volatile byte count = 0;
byte old_count = 0;
void setup()
{
Serial.begin(115200);
Serial.println("Start");
pinMode(interruptPin, INPUT);
attachInterrupt(digitalPinToInterrupt(interruptPin), on_change_state, CHANGE);
}
void loop()
{
// The interrupts are kept running,
// while using the variables.
// That means that the variables
// can change during these lines of code.
if(count != old_count)
{
Serial.print(count);
old_count = count;
Serial.print(" 0x");
byte reg = PIND;
if(reg < 0x10)
Serial.print("0");
Serial.print(reg,HEX);
Serial.print(" ");
int bit = bitRead(PIND,PD2);
Serial.print(bit == 0 ? "low" : "high");
Serial.println();
}
}
void on_change_state()
{
count++;
}
low
high