const int led1 = 2;
const int led2 = 3;
const int led3 = 4;
const int led4 = 5;
const int led5 = 6;
const int led6 = 7;
const int led7 = 8;
const int led8 = 9;
const int BUTTON1Pin= 12 ;
const int BUTTON2Pin= 11 ;
const int BUTTON3Pin= 10 ;
const int BUTTON4Pin= 13 ;
int BUTTON1State = 0;
int BUTTON2State = 0;
int BUTTON3State = 0;
int BUTTON4State = 0;
void setup() {
pinMode(led1,OUTPUT);
pinMode(led2,OUTPUT);
pinMode(led3,OUTPUT);
pinMode(led4,OUTPUT);
pinMode(led5,OUTPUT);
pinMode(led6,OUTPUT);
pinMode(led7,OUTPUT);
pinMode(led8,OUTPUT);
pinMode(BUTTON1Pin,INPUT);
pinMode(BUTTON2Pin,INPUT);
pinMode(BUTTON3Pin,INPUT);
pinMode(BUTTON4Pin,INPUT);
}
void loop() {
BUTTON1State = digitalRead(BUTTON1Pin);
BUTTON2State = digitalRead(BUTTON2Pin);
BUTTON3State = digitalRead(BUTTON3Pin);
BUTTON4State = digitalRead(BUTTON4Pin);
if (BUTTON1State == HIGH) {
// turn LED on:
digitalWrite(led1 , HIGH);
digitalWrite(led2 , HIGH);
digitalWrite(led3 , HIGH);
digitalWrite(led4 , HIGH);
digitalWrite(led5 , HIGH);
digitalWrite(led6 , HIGH);
digitalWrite(led7 , HIGH);
digitalWrite(led8 , HIGH);
delay(900);
digitalWrite(led1 , LOW);
digitalWrite(led2 , LOW);
digitalWrite(led3 , LOW);
digitalWrite(led4 , LOW);
digitalWrite(led5 , LOW);
digitalWrite(led6 , LOW);
digitalWrite(led7 , LOW);
digitalWrite(led8 , LOW);
delay(100);
digitalWrite(led1 , HIGH);
digitalWrite(led2 , LOW);
digitalWrite(led3 , HIGH);
digitalWrite(led4 , LOW);
digitalWrite(led5 , HIGH);
digitalWrite(led6 , LOW);
digitalWrite(led7 , HIGH);
digitalWrite(led8 , LOW);
delay(900);
digitalWrite(led1 , LOW);
digitalWrite(led2 , LOW);
digitalWrite(led3 , LOW);
digitalWrite(led4 , LOW);
digitalWrite(led5 , LOW);
digitalWrite(led6 , LOW);
digitalWrite(led7 , LOW);
digitalWrite(led8 , LOW);
delay(100);
digitalWrite(led1 , LOW);
digitalWrite(led2 , HIGH);
digitalWrite(led3 , LOW);
digitalWrite(led4 , HIGH);
digitalWrite(led5 , LOW);
digitalWrite(led6 , HIGH);
digitalWrite(led7 , LOW);
digitalWrite(led8 , HIGH);
delay(900);
digitalWrite(led1 , LOW);
digitalWrite(led2 , LOW);
digitalWrite(led3 , LOW);
digitalWrite(led4 , LOW);
digitalWrite(led5 , LOW);
digitalWrite(led6 , LOW);
digitalWrite(led7 , LOW);
digitalWrite(led8 , LOW);
delay(100);
digitalWrite(led1 , HIGH);
digitalWrite(led2 , HIGH);
digitalWrite(led3 , HIGH);
digitalWrite(led4 , HIGH);
digitalWrite(led5 , HIGH);
digitalWrite(led6 , HIGH);
digitalWrite(led7 , HIGH);
digitalWrite(led8 , HIGH);
delay(900);
digitalWrite(led1 , LOW);
digitalWrite(led2 , LOW);
digitalWrite(led3 , LOW);
digitalWrite(led4 , LOW);
digitalWrite(led5 , LOW);
digitalWrite(led6 , LOW);
digitalWrite(led7 , LOW);
digitalWrite(led8 , LOW);
delay(100);
digitalWrite(led1 , HIGH);
digitalWrite(led2 , LOW);
digitalWrite(led3 , HIGH);
digitalWrite(led4 , LOW);
digitalWrite(led5 , HIGH);
digitalWrite(led6 , LOW);
digitalWrite(led7 , HIGH);
digitalWrite(led8 , LOW);
delay(900);
digitalWrite(led1 , LOW);
digitalWrite(led2 , LOW);
digitalWrite(led3 , LOW);
digitalWrite(led4 , LOW);
digitalWrite(led5 , LOW);
digitalWrite(led6 , LOW);
digitalWrite(led7 , LOW);
digitalWrite(led8 , LOW);
delay(100);
digitalWrite(led1 , LOW);
digitalWrite(led2 , HIGH);
digitalWrite(led3 , LOW);
digitalWrite(led4 , HIGH);
digitalWrite(led5 , LOW);
digitalWrite(led6 , HIGH);
digitalWrite(led7 , LOW);
digitalWrite(led8 , HIGH);
delay(900);
digitalWrite(led1 , LOW);
digitalWrite(led2 , LOW);
digitalWrite(led3 , LOW);
digitalWrite(led4 , LOW);
digitalWrite(led5 , LOW);
digitalWrite(led6 , LOW);
digitalWrite(led7 , LOW);
digitalWrite(led8 , LOW);
delay(100);
} else {
digitalWrite(led1 , LOW);
digitalWrite(led2 , LOW);
digitalWrite(led3 , LOW);
digitalWrite(led4 , LOW);
digitalWrite(led5 , LOW);
digitalWrite(led6 , LOW);
digitalWrite(led7 , LOW);
digitalWrite(led8 , LOW);
delay(100);
}
if (BUTTON2State == HIGH) {
digitalWrite(led1 , HIGH);
delay(100);
digitalWrite(led1 , LOW);
digitalWrite(led2 , HIGH);
delay(100);
digitalWrite(led2 , LOW);
digitalWrite(led3 , HIGH);
delay(100);
digitalWrite(led3 , LOW);
digitalWrite(led4 , HIGH);
delay(100);
digitalWrite(led4 , LOW);
digitalWrite(led5 , HIGH);
delay(100);
digitalWrite(led5 , LOW);
digitalWrite(led6 , HIGH);
delay(100);
digitalWrite(led6 , LOW);
digitalWrite(led7 , HIGH);
delay(100);
digitalWrite(led7 , LOW);
digitalWrite(led8 , HIGH);
delay(100);
digitalWrite(led8 , LOW);
delay(100);//this is the break
digitalWrite(led8 , HIGH);
delay(100);
digitalWrite(led8 , LOW);
digitalWrite(led7 , HIGH);
delay(100);
digitalWrite(led7 , LOW);
digitalWrite(led6 , HIGH);
delay(100);
digitalWrite(led6 , LOW);
digitalWrite(led5 , HIGH);
delay(100);
digitalWrite(led5 , LOW);
digitalWrite(led4 , HIGH);
delay(100);
digitalWrite(led4 , LOW);
digitalWrite(led3 , HIGH);
delay(100);
digitalWrite(led3 , LOW);
digitalWrite(led2 , HIGH);
delay(100);
digitalWrite(led2 , LOW);
digitalWrite(led1 , HIGH);
delay(100);
digitalWrite(led1 , LOW);
delay(100);//this is the break
digitalWrite(led1 , HIGH);
delay(100);
digitalWrite(led1 , LOW);
digitalWrite(led2 , HIGH);
delay(100);
digitalWrite(led2 , LOW);
digitalWrite(led3 , HIGH);
delay(100);
digitalWrite(led3 , LOW);
digitalWrite(led4 , HIGH);
delay(100);
digitalWrite(led4 , LOW);
digitalWrite(led5 , HIGH);
delay(100);
digitalWrite(led5 , LOW);
digitalWrite(led6 , HIGH);
delay(100);
digitalWrite(led6 , LOW);
digitalWrite(led7 , HIGH);
delay(100);
digitalWrite(led7 , LOW);
digitalWrite(led8 , HIGH);
delay(100);
digitalWrite(led8 , LOW);
delay(100);//this is the break
digitalWrite(led8 , HIGH);
delay(100);
digitalWrite(led8 , LOW);
digitalWrite(led7 , HIGH);
delay(100);
digitalWrite(led7 , LOW);
digitalWrite(led6 , HIGH);
delay(100);
digitalWrite(led6 , LOW);
digitalWrite(led5 , HIGH);
delay(100);
digitalWrite(led5 , LOW);
digitalWrite(led4 , HIGH);
delay(100);
digitalWrite(led4 , LOW);
digitalWrite(led3 , HIGH);
delay(100);
digitalWrite(led3 , LOW);
digitalWrite(led2 , HIGH);
delay(100);
digitalWrite(led2 , LOW);
digitalWrite(led1 , HIGH);
delay(100);
digitalWrite(led1 , LOW);
delay(100);//this is the break
}else{
digitalWrite(led1 , LOW);
digitalWrite(led2 , LOW);
digitalWrite(led3 , LOW);
digitalWrite(led4 , LOW);
digitalWrite(led5 , LOW);
digitalWrite(led6 , LOW);
digitalWrite(led7 , LOW);
digitalWrite(led8 , LOW);
delay(100);
}
if (BUTTON3State == HIGH) {
digitalWrite(led1 , HIGH);
delay(100);
digitalWrite(led2 , HIGH);
delay(100);
digitalWrite(led3 , HIGH);
delay(100);
digitalWrite(led4 , HIGH);
delay(100);
digitalWrite(led5 , HIGH);
delay(100);
digitalWrite(led6 , HIGH);
delay(100);
digitalWrite(led7 , HIGH);
delay(100);
digitalWrite(led8 , HIGH);
delay(100);
digitalWrite(led1 , LOW);
delay(100);
digitalWrite(led2 , LOW);
delay(100);
digitalWrite(led3 , LOW);
delay(100);
digitalWrite(led4 , LOW);
delay(100);
digitalWrite(led5 , LOW);
delay(100);
digitalWrite(led6 , LOW);
delay(100);
digitalWrite(led7 , LOW);
delay(100);
digitalWrite(led8 ,LOW);
delay(100);//this is the break
digitalWrite(led8 , HIGH);
delay(100);
digitalWrite(led7 , HIGH);
delay(100);
digitalWrite(led6 , HIGH);
delay(100);
digitalWrite(led5 , HIGH);
delay(100);
digitalWrite(led4 , HIGH);
delay(100);
digitalWrite(led3 , HIGH);
delay(100);
digitalWrite(led2 , HIGH);
delay(100);
digitalWrite(led1 , HIGH);
delay(100);
digitalWrite(led8 , LOW);
delay(100);
digitalWrite(led7 , LOW);
delay(100);
digitalWrite(led6 , LOW);
delay(100);
digitalWrite(led5 , LOW);
delay(100);
digitalWrite(led4 , LOW);
delay(100);
digitalWrite(led3 , LOW);
delay(100);
digitalWrite(led2 , LOW);
delay(100);
digitalWrite(led1 , LOW);
delay(100);//this is the break
digitalWrite(led1 , HIGH);
delay(100);
digitalWrite(led2 , HIGH);
delay(100);
digitalWrite(led3 , HIGH);
delay(100);
digitalWrite(led4 , HIGH);
delay(100);
digitalWrite(led5 , HIGH);
delay(100);
digitalWrite(led6 , HIGH);
delay(100);
digitalWrite(led7 , HIGH);
delay(100);
digitalWrite(led8 , HIGH);
delay(100);
digitalWrite(led8 , LOW);
delay(100);
digitalWrite(led7 , LOW);
delay(100);
digitalWrite(led6 , LOW);
delay(100);
digitalWrite(led5 , LOW);
delay(100);
digitalWrite(led4 , LOW);
delay(100);
digitalWrite(led3 , LOW);
delay(100);
digitalWrite(led2 , LOW);
delay(100);
digitalWrite(led1 ,LOW);
delay(100);//this is the break
digitalWrite(led8 , HIGH);
delay(100);
digitalWrite(led7 , HIGH);
delay(100);
digitalWrite(led6 , HIGH);
delay(100);
digitalWrite(led5 , HIGH);
delay(100);
digitalWrite(led4 , HIGH);
delay(100);
digitalWrite(led3 , HIGH);
delay(100);
digitalWrite(led2 , HIGH);
delay(100);
digitalWrite(led1 , HIGH);
delay(100);
digitalWrite(led1 , LOW);
delay(100);
digitalWrite(led2 , LOW);
delay(100);
digitalWrite(led3 , LOW);
delay(100);
digitalWrite(led4 , LOW);
delay(100);
digitalWrite(led5 , LOW);
delay(100);
digitalWrite(led6 , LOW);
delay(100);
digitalWrite(led7 , LOW);
delay(100);
digitalWrite(led8 , LOW);
delay(100);
} else{
digitalWrite(led1 , LOW);
digitalWrite(led2 , LOW);
digitalWrite(led3 , LOW);
digitalWrite(led4 , LOW);
digitalWrite(led5 , LOW);
digitalWrite(led6 , LOW);
digitalWrite(led7 , LOW);
digitalWrite(led8 , LOW);
delay(100);
}
if (BUTTON4State == HIGH) {
digitalWrite(led1 , HIGH);
digitalWrite(led8 , HIGH);
delay(100);
digitalWrite(led2 , HIGH);
digitalWrite(led7 , HIGH);
delay(100);
digitalWrite(led3 , HIGH);
digitalWrite(led6 , HIGH);
delay(100);
digitalWrite(led4 , HIGH);
digitalWrite(led5 , HIGH);
delay(100);
digitalWrite(led4 , LOW);
digitalWrite(led5 , LOW);
delay(100);
digitalWrite(led3 , LOW);
digitalWrite(led6 , LOW);
delay(100);
digitalWrite(led2 , LOW);
digitalWrite(led7 , LOW);
delay(100);
digitalWrite(led1 , LOW);
digitalWrite(led8 , LOW);
delay(100);//this is the break
digitalWrite(led1 , HIGH);
digitalWrite(led8 , HIGH);
delay(100);
digitalWrite(led2 , HIGH);
digitalWrite(led7 , HIGH);
delay(100);
digitalWrite(led3 , HIGH);
digitalWrite(led6 , HIGH);
delay(100);
digitalWrite(led4 , HIGH);
digitalWrite(led5 , HIGH);
delay(100);
digitalWrite(led1 , LOW);
digitalWrite(led8 , LOW);
delay(100);
digitalWrite(led2 , LOW);
digitalWrite(led7 , LOW);
delay(100);
digitalWrite(led3 , LOW);
digitalWrite(led6 , LOW);
delay(100);
digitalWrite(led4 , LOW);
digitalWrite(led5 , LOW);
delay(100);//this is the brek
digitalWrite(led4 , HIGH);
digitalWrite(led5 , HIGH);
delay(100);
digitalWrite(led3 , HIGH);
digitalWrite(led6 , HIGH);
delay(100);
digitalWrite(led2 , HIGH);
digitalWrite(led7 , HIGH);
delay(100);
digitalWrite(led1 , HIGH);
digitalWrite(led8 , HIGH);
delay(100);
digitalWrite(led4 , LOW);
digitalWrite(led5 , LOW);
delay(100);
digitalWrite(led3 , LOW);
digitalWrite(led6 , LOW);
delay(100);
digitalWrite(led2 , LOW);
digitalWrite(led7 , LOW);
delay(100);
digitalWrite(led1 , LOW);
digitalWrite(led8 , LOW);
delay(100);//this is the break
digitalWrite(led4 , HIGH);
digitalWrite(led5 , HIGH);
delay(100);
digitalWrite(led3 , HIGH);
digitalWrite(led6 , HIGH);
delay(100);
digitalWrite(led2 , HIGH);
digitalWrite(led7 , HIGH);
delay(100);
digitalWrite(led1 , HIGH);
digitalWrite(led8 , HIGH);
delay(100);
digitalWrite(led1 , LOW);
digitalWrite(led8 , LOW);
delay(100);
digitalWrite(led2 , LOW);
digitalWrite(led7 , LOW);
delay(100);
digitalWrite(led3 , LOW);
digitalWrite(led6 , LOW);
delay(100);
digitalWrite(led4 , LOW);
digitalWrite(led5 , LOW);
delay(200);
digitalWrite(led1 , HIGH);
digitalWrite(led8 , HIGH);
delay(100);
digitalWrite(led2 , HIGH);
digitalWrite(led7 , HIGH);
delay(100);
digitalWrite(led3 , HIGH);
digitalWrite(led6 , HIGH);
delay(100);
digitalWrite(led4 , HIGH);
digitalWrite(led5 , HIGH);
delay(100);
digitalWrite(led4 , LOW);
digitalWrite(led5 , LOW);
delay(100);
digitalWrite(led3 , LOW);
digitalWrite(led6 , LOW);
delay(100);
digitalWrite(led2 , LOW);
digitalWrite(led7 , LOW);
delay(100);
digitalWrite(led1 , LOW);
digitalWrite(led8 , LOW);
delay(100);//this is the break
digitalWrite(led1 , HIGH);
digitalWrite(led8 , HIGH);
delay(100);
digitalWrite(led2 , HIGH);
digitalWrite(led7 , HIGH);
delay(100);
digitalWrite(led3 , HIGH);
digitalWrite(led6 , HIGH);
delay(100);
digitalWrite(led4 , HIGH);
digitalWrite(led5 , HIGH);
delay(100);
digitalWrite(led1 , LOW);
digitalWrite(led8 , LOW);
delay(100);
digitalWrite(led2 , LOW);
digitalWrite(led7 , LOW);
delay(100);
digitalWrite(led3 , LOW);
digitalWrite(led6 , LOW);
delay(100);
digitalWrite(led4 , LOW);
digitalWrite(led5 , LOW);
delay(100);//this is the brek
digitalWrite(led4 , HIGH);
digitalWrite(led5 , HIGH);
delay(100);
digitalWrite(led3 , HIGH);
digitalWrite(led6 , HIGH);
delay(100);
digitalWrite(led2 , HIGH);
digitalWrite(led7 , HIGH);
delay(100);
digitalWrite(led1 , HIGH);
digitalWrite(led8 , HIGH);
delay(100);
digitalWrite(led4 , LOW);
digitalWrite(led5 , LOW);
delay(100);
digitalWrite(led3 , LOW);
digitalWrite(led6 , LOW);
delay(100);
digitalWrite(led2 , LOW);
digitalWrite(led7 , LOW);
delay(100);
digitalWrite(led1 , LOW);
digitalWrite(led8 , LOW);
delay(100);//this is the break
digitalWrite(led4 , HIGH);
digitalWrite(led5 , HIGH);
delay(100);
digitalWrite(led3 , HIGH);
digitalWrite(led6 , HIGH);
delay(100);
digitalWrite(led2 , HIGH);
digitalWrite(led7 , HIGH);
delay(100);
digitalWrite(led1 , HIGH);
digitalWrite(led8 , HIGH);
delay(100);
digitalWrite(led1 , LOW);
digitalWrite(led8 , LOW);
delay(100);
digitalWrite(led2 , LOW);
digitalWrite(led7 , LOW);
delay(100);
digitalWrite(led3 , LOW);
digitalWrite(led6 , LOW);
delay(100);
digitalWrite(led4 , LOW);
digitalWrite(led5 , LOW);
delay(200);
} else {
digitalWrite(led1 , LOW);
digitalWrite(led2 , LOW);
digitalWrite(led3 , LOW);
digitalWrite(led4 , LOW);
digitalWrite(led5 , LOW);
digitalWrite(led6 , LOW);
digitalWrite(led7 , LOW);
digitalWrite(led8 , LOW);
delay(100);
}
}
Comments