 LiquidCrystal_I2C lcd(0x27,20,4);
 Servo myservo;
 
-char pass[16];
+char pass[10];
 int attempt = 0;
 int count = 0;
-int max_attempt = 3;
 
 const int sensor = A2;
 const int push_btn = A3;
 const int servo = 9;
 
+long prevTime = 0;
+long idleTime = 0;
+long interval_reset = 180000;
+long interval_idle = 20000;
+
 void setup(){
   Serial.begin(9600);
+  myservo.attach(9);
   Ethernet.begin(mac, ip);
   server.begin();
   pinMode(sensor, INPUT);

    delay(10);
    client.stop();
  }
  if(digitalRead(push_btn) == LOW){
    auth_user("keluar");
    open_door();
  }

  if(device_status){
    char key = keypad.getKey();
    if (key != NO_KEY && key != '*'){
      pass[count] = key;
      count++;
    }
    if(key == '*'){
      attempt++;
      auth_user(pass);
      sys_init();

    if(key == '#'){
      sys_init();
    }
    if(count > 9){
      auth_user(pass);
      sys_init();
    }
  }
  else{
    //Device Non-Active
  }

  unsigned long curTime = millis();
  if(curTime - idleTime > interval_idle){
    idleTime = curTime;
    isInputting = false;
    sys_init();
  }

  if(!isInputting){
    if(curTime - prevTime > interval_reset){
      prevTime = curTime;
      attempt = 0;
    }
  }
}

void sys_init(){
  Serial.println("sys_init()");
  Serial.println(pass);
  memset(pass, 0, 10);
  count = 0;
  Serial.println(pass);
}

void auth_user(char user_input[]){
  EthernetClient client;
  Serial.println(user_input);
  if (client.connect(server_addr,80))
  {
    client.print("GET /api/dcs/dcs_auth/");
    client.print(user_input);
    client.print(" HTTP/1.1\n");
    client.print("Host: 192.168.2.4\n");
    client.print("Connection: close\n\n");
