#define btn1 2 //button 1 pada pin D2 
#define btn2 4 
#define btn3 5 
#define btn4 3
#define btn5 6
#define LED1 11 //LED pada pin D5 
#define LED2 12
#define LED3 13 
#define LED4 9
#define LED5 10
#define restart 7 //button reset pada pin D8 

bool lock = false ;

void setup() {
pinMode(btn1, INPUT); // setting I/0
pinMode(btn2, INPUT);
pinMode(btn3, INPUT);
pinMode(btn4, INPUT);
pinMode(btn5, INPUT);
pinMode(LED1, OUTPUT);
pinMode(LED2, OUTPUT);
pinMode(LED3, OUTPUT);
pinMode(LED4, OUTPUT);
pinMode(LED5, OUTPUT);
pinMode(restart, INPUT);
}

void loop() {
 if (lock == false  ){  //jika kunci terbuka, maka 
   if (digitalRead (btn1) == HIGH){   //jika button 1 ditekan, maka 
     digitalWrite(LED1, HIGH);   //LED 1 akan menyala 
     lock = true;     
    } //mengunci 
 
else   if(digitalRead(btn2) == HIGH){
  digitalWrite(LED2, HIGH);
  lock = true;
 }
 else if(digitalRead(btn3) == HIGH){
   digitalWrite(LED3, HIGH);
   lock = true;
 }
else if (digitalRead (btn4) == HIGH){
  digitalWrite (LED4,HIGH );
  lock= true;
}
else if (digitalRead (btn5) == HIGH){
  digitalWrite (LED5,HIGH );
  lock= true;
}
 }
  else{                   //jika terkunci,maka 
  if (digitalRead(restart) == HIGH){
    lock = false;      //terbuka kalau tombol reset ditekan 
    digitalWrite(LED1, LOW);
    digitalWrite(LED2, LOW);
    digitalWrite(LED3, LOW);
    digitalWrite(LED4, LOW);
    digitalWrite(LED5, LOW);
    delay(200);
  }
  }
 }