int sw1 = 13;
int led1 = 26;
int led2 = 25;
int led3 = 33;
int led4 = 32;
int count =0;
void setup() {
Serial.begin (9600);
pinMode (sw1, INPUT_PULLUP);
pinMode (led1, OUTPUT);
pinMode (led2, OUTPUT);
pinMode (led3, OUTPUT);
pinMode (led4, OUTPUT);
}
void loop() {
int value1 = digitalRead (sw1);
if (value1 == 0) {
delay(200);
count ++;
if (count > 4) {
count = 0 ;
}
Serial.println ("count:" + String(count));
}
if (count == 0) {
digitalWrite(led1, 0);
digitalWrite(led2, 0);
digitalWrite(led3, 0);
digitalWrite(led4, 0);
} else if (count == 1) {
digitalWrite(led1, 1);
digitalWrite(led2, 0);
digitalWrite(led3, 0);
digitalWrite(led4, 0);
} else if (count == 2) {
digitalWrite(led1, 1);
digitalWrite(led2, 1);
digitalWrite(led3, 0);
digitalWrite(led4, 0);
} else if (count == 3) {
digitalWrite(led1, 1);
digitalWrite(led2, 1);
digitalWrite(led3, 1);
digitalWrite(led4, 0);
} else if (count == 4) {
digitalWrite(led1, 1);
digitalWrite(led2, 1);
digitalWrite(led3, 1);
digitalWrite(led4, 1);
}
}