#define led1 4
#define led2 5
#define sw1 2
byte timer = 0;
byte cnt = 0;
byte x;
/* ----------------------------------------------------- */
void setup() {
pinMode(led1, OUTPUT);
pinMode(led2, OUTPUT);
pinMode(sw1, INPUT);
Serial.begin(9600);
Serial.println();
Serial.println("Wait Timer On !");
}
/* ------------------------------------------------------ */
void loop() {
/* ------------------------------------------------- */
boolean SW1 = digitalRead(sw1);
boolean LED = digitalRead(led1);
boolean LED1 = digitalRead(led2);
//switch1
if (SW1 == 0) {
while (digitalRead(sw1) == 0) {
delay(10);
}
cnt++; timer = 0; if (cnt > 2) {
cnt = 2;
}
}
if(timer == 20){
if (cnt == 1 ){x=!x;
digitalWrite(led1, x);
delay(200);
}
if (cnt == 2 ){x=!x;
digitalWrite(led2, x);
delay(200);
}
timer = 0;
cnt = 0;
}
timer++;
Serial.println("Timer:" + String(timer));
Serial.println("cnt:" + String(cnt));
// Serial.println("led:" + String(LED));
//Serial.println("led:" + String(LED1));
delay(200);
}