#define led 9
#define sw1 5
#define sw2 6
byte timer=0;
byte cnt=0;
/* ----------------------------------------------------- */
void setup() {
pinMode(led, OUTPUT);
pinMode(sw1, INPUT_PULLUP);
pinMode(sw2, INPUT_PULLUP);
Serial.begin(9600);
Serial.println();
Serial.println("Wiat Timer On !");
}
/* ------------------------------------------------------ */
void loop() {
if(digitalRead(sw1)== 0){
while(digitalRead(sw1) == 0) delay(10);
cnt++;
if(cnt>=5) cnt=5;
timer = 0;
}
if(digitalRead(sw2)==0){
while(digitalRead(sw2) == 0) delay(10);
cnt++;
if(cnt>=255) cnt=0;
timer = 0;
}
if(timer == 30){
int x;
for(x=0; x<cnt; x++){
digitalWrite(led, HIGH);
delay(300);
digitalWrite(led, LOW);
delay(300);
}
cnt = 0;
timer = 0;
}
timer++;
Serial.println("Timer:"+String(timer));
Serial.println("cnt:"+String(cnt));
delay(100);
}