#define LED1 2
#define LED2 3
#define LED3 4
#define LED4 5
#define SW1 9
#define SW2 10
#define SW3 11
#define SW4 12
void setup(){
pinMode(LED1,OUTPUT);pinMode(LED2,OUTPUT);
pinMode(LED3,OUTPUT); pinMode(LED4,OUTPUT);
pinMode(SW1,INPUT_PULLUP);pinMode(SW2,INPUT_PULLUP);
pinMode(SW3,INPUT_PULLUP);pinMode(SW4,INPUT_PULLUP);
Serial.begin(9600);
}
void loop(){
if(digitalRead(SW1)==LOW)
{
if (digitalRead(LED1)==LOW)
{
digitalWrite(LED1,HIGH);
digitalWrite(LED3,LOW);
delay(500);
}
else if (digitalRead(LED1)==HIGH)
{
digitalWrite(LED1,LOW);
digitalWrite(LED3,HIGH);
delay(500);
}
}
if(digitalRead(SW2)==LOW)
{
if (digitalRead(LED2)==LOW)
{
digitalWrite(LED2,HIGH);
digitalWrite(LED4,LOW);
delay(500);
}
else if (digitalRead(LED2)==HIGH)
{
digitalWrite(LED2,LOW);
digitalWrite(LED4,HIGH);
delay(500);
}
}
if(digitalRead(SW3)==LOW )
{
if (digitalRead(LED1)==LOW || digitalRead(LED3)==LOW)
{
digitalWrite(LED1,HIGH);
digitalWrite(LED2,HIGH);
digitalWrite(LED3,HIGH);
digitalWrite(LED4,HIGH);
delay(500);
}
else if (digitalRead(LED1)==HIGH)
{
digitalWrite(LED1,LOW);
digitalWrite(LED2,LOW);
digitalWrite(LED3,LOW);
digitalWrite(LED4,LOW);
delay(500);
}
}
int num = random(2,6) ;
if(digitalRead(SW4)==LOW )
{
digitalWrite(LED1,LOW);
digitalWrite(LED2,LOW);
digitalWrite(LED3,LOW);
digitalWrite(LED4,LOW);
if (digitalRead(num)==LOW)
{
digitalWrite(num,HIGH);
delay(500);
}
}
}