const int btnPin=15;
int num=0;
bool flag=false;
void echo(){
flag=true;
num++;
}
void setup() {
// put your setup code here, to run once:
Serial.begin(115200);
pinMode(btnPin, INPUT);
attachInterrupt(btnPin, echo, CHANGE);
}
void loop() {
// put your main code here, to run repeatedly:
if (flag) {
Serial.println(num);
num=0;
}
flag=false;
}