نقل قول:
	
		
		
			#include <Bounce2.h>
#include <Timer.h>
int tm,i,z;
int buttonPushCounter = 0;   // counter for the number of button presses
int buttonState = 0;         // current state of the button
int lastButtonState = 0;
const int buttonPin= 16;// previous state of the button
Timer t;
Bounce debouncer = Bounce(); 
void setup() {
  pinMode(22,INPUT);//define pinMode
  pinMode(23,INPUT);
  pinMode(16,INPUT);
   debouncer.attach(16);
  debouncer.interval(5);
  Serial.begin(9600);
      delay(2000);
  tm=0;
}
void loop(){
while(1){
  Serial.print("press9 up,10 down");
  Serial.print(tm);
delay (1000);
if (digitalRead(22)==LOW){
    tm++;
    while(digitalRead(22)==HIGH);
    Serial.println(tm);
  
}
if (digitalRead(23)==LOW)
{   tm--;
    while(digitalRead(23)==HIGH);
    Serial.println(tm);
    
}
if(tm<0){tm=0;}
if(digitalRead( 16)==LOW){
  Serial.print("you are ready...");
  delay(10);
  tm=tm*60*1000;
  for (i=3;i>0;i--){
  Seial.print(i);
  delay(1000);
  }
  while(1){
  t.update();
  t.after(tm, resultTap);
    debouncer.update();
 // read the pushbutton input pin:
  buttonState = debouncer.read();
Serial.print("number of button pushes:  ");
  if (buttonState != lastButtonState) {
    if (buttonState == LOW) {
      buttonPushCounter++;
      Serial.println(buttonPushCounter);
    } 
    
   delay(50);
  }
  
  lastButtonState = buttonState;
  }
  
}
}
}
void resultTap(){
  t.stop(z);//timer stop
  Serial.print("number of result:  ");//showing number of push
  Serial.println(buttonPushCounter);
  delay(5000);
}