#define SW1 4
#define SW2 16
int KeyPressesSW1 = 0;
bool statusSW1 = false;
int KeyPressesSW2 = 0;
bool statusSW2 = false;
void IRAM_ATTR isrSW1 (){
KeyPressesSW1 += 1;
statusSW1 = true;
}
void IRAM_ATTR isrSW2 (){
KeyPressesSW2 += 1;
statusSW2 = true;
}
void setup() {
Serial.begin(115200);
pinMode(4,INPUT);
pinMode(16,INPUT);
attachInterrupt(4,isrSW1,CHANGE);
attachInterrupt(16,isrSW2,CHANGE);
}
void loop() {
// put your main code here, to run repeatedly:
if(statusSW1){
Serial.printf("SW1 press %u times\n",KeyPressesSW1);
statusSW1=false;
}
if(statusSW2){
Serial.printf("SW2 press %u times\n",KeyPressesSW2);
statusSW2=false;
}
}