const int p_button = 23;
volatile int n_presses = 0;
volatile boolean pressed = false;
void IRAM_ATTR ISR_button() {
n_presses++;
pressed = true;
}
void setup() {
// put your setup code here, to run once:
Serial.begin(115200);
pinMode(p_button, INPUT_PULLUP);
attachInterrupt(p_button, ISR_button, FALLING);
}
void loop() {
// put your main code here, to run repeatedly:
if (pressed) {
Serial.printf("Button pressed %d times\n", n_presses);
pressed = false;
}
}